yasserrmd commited on
Commit
b5d4a49
·
verified ·
1 Parent(s): 79904bc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -16
app.py CHANGED
@@ -1,26 +1,28 @@
1
  import gradio as gr
2
- from unsloth import FastLanguageModel
3
  from transformers import TextIteratorStreamer
4
  from threading import Thread
5
  import spaces
6
 
7
- # Model configuration
8
- model_name = "yasserrmd/food_safety"
9
- max_seq_length = 512
10
- load_in_4bit = True
11
- dtype = "fp16"
12
-
13
- # Load model and tokenizer
14
- model, tokenizer = FastLanguageModel.from_pretrained(
15
- model_name=model_name,
16
- max_seq_length=max_seq_length,
17
- dtype=dtype,
18
- load_in_4bit=load_in_4bit,
19
- )
20
- FastLanguageModel.for_inference(model) # Enable faster inference
21
-
22
  @spaces.GPU
23
  def food_safety_query(prompt):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  messages = [
25
  {"role": "system", "content": "You are an AI assistant with expertise in food safety. Your primary goal is to provide precise, actionable, and scientifically accurate responses to queries about food safety practices, standards, and regulations. Focus on offering guidance based on global food safety standards, such as HACCP, ISO 22000, and FDA guidelines. Your responses should address hygiene, contamination prevention, food handling, storage, production processes, and safety protocols with practical and specific advice."},
26
  {"role": "user", "content": prompt},
 
1
  import gradio as gr
2
+
3
  from transformers import TextIteratorStreamer
4
  from threading import Thread
5
  import spaces
6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  @spaces.GPU
8
  def food_safety_query(prompt):
9
+ from unsloth import FastLanguageModel
10
+ # Model configuration
11
+ model_name = "yasserrmd/food_safety"
12
+ max_seq_length = 512
13
+ load_in_4bit = True
14
+ dtype = "fp16"
15
+
16
+ # Load model and tokenizer
17
+ model, tokenizer = FastLanguageModel.from_pretrained(
18
+ model_name=model_name,
19
+ max_seq_length=max_seq_length,
20
+ dtype=dtype,
21
+ load_in_4bit=load_in_4bit,
22
+ )
23
+ FastLanguageModel.for_inference(model) # Enable faster inference
24
+
25
+
26
  messages = [
27
  {"role": "system", "content": "You are an AI assistant with expertise in food safety. Your primary goal is to provide precise, actionable, and scientifically accurate responses to queries about food safety practices, standards, and regulations. Focus on offering guidance based on global food safety standards, such as HACCP, ISO 22000, and FDA guidelines. Your responses should address hygiene, contamination prevention, food handling, storage, production processes, and safety protocols with practical and specific advice."},
28
  {"role": "user", "content": prompt},