Spaces:
Runtime error
Runtime error
adrien.aribaut-gaudin
commited on
Commit
•
ed437ad
1
Parent(s):
b548316
updating to real llama2
Browse files- app.py +2 -2
- src/tools/llm.py +3 -2
app.py
CHANGED
@@ -36,12 +36,12 @@ client_db = chromadb.Client()
|
|
36 |
|
37 |
try:
|
38 |
client_db.get_collection(name="illumio_database")
|
39 |
-
llm = LlmAgent(model="
|
40 |
retriever = Retriever(client_db, None, "illumio_database", llmagent=llm)
|
41 |
except:
|
42 |
print("Database is empty")
|
43 |
doc = Doc(path=content_en_path_real)
|
44 |
-
llm = LlmAgent(model="
|
45 |
retriever = Retriever(client_db,doc.container,"illumio_database",llmagent=llm)
|
46 |
|
47 |
|
|
|
36 |
|
37 |
try:
|
38 |
client_db.get_collection(name="illumio_database")
|
39 |
+
llm = LlmAgent(model="meta-llama/Llama-2-7b")
|
40 |
retriever = Retriever(client_db, None, "illumio_database", llmagent=llm)
|
41 |
except:
|
42 |
print("Database is empty")
|
43 |
doc = Doc(path=content_en_path_real)
|
44 |
+
llm = LlmAgent(model="meta-llama/Llama-2-7b")
|
45 |
retriever = Retriever(client_db,doc.container,"illumio_database",llmagent=llm)
|
46 |
|
47 |
|
src/tools/llm.py
CHANGED
@@ -2,16 +2,17 @@ from langchain.llms.huggingface_pipeline import HuggingFacePipeline
|
|
2 |
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
|
3 |
from langchain.chains import LLMChain
|
4 |
from langchain.prompts import PromptTemplate
|
|
|
5 |
|
6 |
class LlmAgent:
|
7 |
|
8 |
-
def __init__(self, model :str = "
|
9 |
self.tokenizer = AutoTokenizer.from_pretrained(model, use_fast=True)
|
10 |
self.model = AutoModelForCausalLM.from_pretrained(model,
|
11 |
device_map="cuda",
|
12 |
trust_remote_code=False, #A CHANGER SELON LES MODELES, POUR CELUI DE LAMA2 CA MARCHE (celui par default)
|
13 |
revision="main")
|
14 |
-
self.pipe = pipeline("text-generation", model=self.model, tokenizer=self.tokenizer)
|
15 |
|
16 |
def generate_paragraph(self, query: str, context: {}, histo: [(str, str)], language='fr') -> str:
|
17 |
locallm = HuggingFacePipeline(pipeline=self.pipe)
|
|
|
2 |
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
|
3 |
from langchain.chains import LLMChain
|
4 |
from langchain.prompts import PromptTemplate
|
5 |
+
import torch
|
6 |
|
7 |
class LlmAgent:
|
8 |
|
9 |
+
def __init__(self, model :str = "meta-llama/Llama-2-7b"):
|
10 |
self.tokenizer = AutoTokenizer.from_pretrained(model, use_fast=True)
|
11 |
self.model = AutoModelForCausalLM.from_pretrained(model,
|
12 |
device_map="cuda",
|
13 |
trust_remote_code=False, #A CHANGER SELON LES MODELES, POUR CELUI DE LAMA2 CA MARCHE (celui par default)
|
14 |
revision="main")
|
15 |
+
self.pipe = pipeline("text-generation", model=self.model, tokenizer=self.tokenizer,torch_dtype=torch.float16)
|
16 |
|
17 |
def generate_paragraph(self, query: str, context: {}, histo: [(str, str)], language='fr') -> str:
|
18 |
locallm = HuggingFacePipeline(pipeline=self.pipe)
|