BMike10 commited on
Commit
9114b27
1 Parent(s): 288ddad

Inital Configuration ITACA

Browse files
Files changed (2) hide show
  1. app.py +17 -4
  2. requirements.txt +4 -4
app.py CHANGED
@@ -1,8 +1,21 @@
1
- from transformers import pipeline
2
  import gradio as gr
 
 
 
 
 
 
 
 
 
 
3
 
 
 
 
 
 
4
 
5
- pipe = pipeline("text-generation", model="michelebasilico/PROVA")
6
 
7
- demo = gr.Interface.from_pipeline(pipe)
8
- demo.launch()
 
 
1
  import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # model="michelebasilico/itaca-mistral-7b-v2-4bit")
5
+ model = pipeline("text-generation",
6
+ model="michelebasilico/itaca-mistral-7b-v2-16bit")
7
+ start_token = "<s>"
8
+ start_completion = "\nRisposta:"
9
+ start_instruction_token, end_instruction_token = "[INST]", "[/INST]"
10
+ system_prompt = "Sei un assistente utile ed affidabile. Rispondi in maniera adeguata alla domanda seguente:"
11
+
12
 
13
+ def predict(message, history):
14
+ new_message = start_instruction_token + system_prompt + \
15
+ message + end_instruction_token + start_completion
16
+ outputs = model(new_message)[0]["generated_text"]
17
+ return outputs
18
 
 
19
 
20
+ iface = gr.ChatInterface(predict)
21
+ iface.launch()
requirements.txt CHANGED
@@ -1,4 +1,4 @@
1
- torch==2.0.1
2
- transformers==4.34.0
3
- bitsandbytes==0.41.1
4
- accelerate==0.23.0
 
1
+ torch
2
+ transformers
3
+ bitsandbytes
4
+ accelerate