Spaces:
Sleeping
Sleeping
Commit
·
94788eb
1
Parent(s):
b1cd233
switched to llama instruct
Browse files
app.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
import gradio as gr
|
2 |
-
from huggingface_hub import InferenceClient
|
3 |
import os
|
4 |
import cohere
|
5 |
import pickle
|
@@ -7,7 +7,9 @@ from annoy import AnnoyIndex
|
|
7 |
|
8 |
HF_TOKEN = os.getenv("HUGGINGFACE_TOKEN")
|
9 |
|
|
|
10 |
client = InferenceClient(token=HF_TOKEN)
|
|
|
11 |
system_message = """Tu es un assistant juridique spécialisé dans le Code de l'éducation français.
|
12 |
Ta mission est d'aider les utilisateurs à comprendre la législation en répondant à leurs questions.
|
13 |
|
@@ -60,12 +62,13 @@ def query_rag(query, model, with_paths=True):
|
|
60 |
|
61 |
article_dict = {}
|
62 |
context_list = []
|
63 |
-
for i in reversed(similar_item_ids[0]):
|
64 |
article = articles[i]
|
65 |
context_list.append(article['path']+'\n'+article['text']+'\n---\n')
|
66 |
article_dict[article['article']] = '**' + article['path'] + '** ' + article['text']
|
67 |
|
68 |
user = 'Question de l\'utilisateur : ' + query + '\nContexte législatif :\n' + '\n'.join(context_list)
|
|
|
69 |
messages = [ { "role" : "system", "content" : system_prompt } ]
|
70 |
messages.append( { "role" : "user", "content" : user } )
|
71 |
|
@@ -105,8 +108,8 @@ with gr.Blocks(title="Assistant Juridique pour le Code de l'éducation (Beta)")
|
|
105 |
model = gr.Dropdown(
|
106 |
label="Modèle de langage",
|
107 |
choices=[
|
108 |
-
"meta-llama/Meta-Llama-3-70B",
|
109 |
-
"meta-llama/Meta-Llama-3-8B",
|
110 |
"HuggingFaceH4/zephyr-7b-beta",
|
111 |
"NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO",
|
112 |
"mistralai/Mixtral-8x22B-v0.1"
|
|
|
1 |
import gradio as gr
|
2 |
+
from huggingface_hub import login, InferenceClient
|
3 |
import os
|
4 |
import cohere
|
5 |
import pickle
|
|
|
7 |
|
8 |
HF_TOKEN = os.getenv("HUGGINGFACE_TOKEN")
|
9 |
|
10 |
+
login(token=HF_TOKEN)
|
11 |
client = InferenceClient(token=HF_TOKEN)
|
12 |
+
|
13 |
system_message = """Tu es un assistant juridique spécialisé dans le Code de l'éducation français.
|
14 |
Ta mission est d'aider les utilisateurs à comprendre la législation en répondant à leurs questions.
|
15 |
|
|
|
62 |
|
63 |
article_dict = {}
|
64 |
context_list = []
|
65 |
+
for i in reversed(similar_item_ids[0][:5]):
|
66 |
article = articles[i]
|
67 |
context_list.append(article['path']+'\n'+article['text']+'\n---\n')
|
68 |
article_dict[article['article']] = '**' + article['path'] + '** ' + article['text']
|
69 |
|
70 |
user = 'Question de l\'utilisateur : ' + query + '\nContexte législatif :\n' + '\n'.join(context_list)
|
71 |
+
|
72 |
messages = [ { "role" : "system", "content" : system_prompt } ]
|
73 |
messages.append( { "role" : "user", "content" : user } )
|
74 |
|
|
|
108 |
model = gr.Dropdown(
|
109 |
label="Modèle de langage",
|
110 |
choices=[
|
111 |
+
"meta-llama/Meta-Llama-3-70B-Instruct",
|
112 |
+
"meta-llama/Meta-Llama-3-8B-Instruct",
|
113 |
"HuggingFaceH4/zephyr-7b-beta",
|
114 |
"NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO",
|
115 |
"mistralai/Mixtral-8x22B-v0.1"
|