Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -15,12 +15,11 @@ from langchain_community.embeddings import HuggingFaceEmbeddings
|
|
15 |
#from transformers import pipeline
|
16 |
# Load model directly
|
17 |
#from transformers import AutoModelForCausalLM
|
18 |
-
from
|
|
|
19 |
|
20 |
-
HUGGINGFACEHUB_API_TOKEN = getpass()
|
21 |
|
22 |
|
23 |
-
os.environ["HUGGINGFACEHUB_API_TOKEN"] = HUGGINGFACEHUB_API_TOKEN
|
24 |
#access_token = os.getenv("HUGGINGFACE_API_KEY")
|
25 |
|
26 |
|
@@ -92,12 +91,16 @@ def get_conversational_chain(retriever):
|
|
92 |
#repo_id='meta-llama/Meta-Llama-3-70B'
|
93 |
#repo_id = 'mistralai/Mixtral-8x7B-Instruct-v0.1'
|
94 |
#repo_id= 'nvidia/Llama3-ChatQA-1.5-8B'
|
95 |
-
repo_id= 'google/gemma-1.1-2b-it'
|
96 |
-
llm = HuggingFaceEndpoint(repo_id=repo_id, temperature=0.3,token = HUGGINGFACEHUB_API_TOKEN)
|
97 |
#tokenizer = AutoTokenizer.from_pretrained("google/gemma-1.1-2b-it")
|
98 |
#llm = AutoModelForCausalLM.from_pretrained("google/gemma-1.1-2b-it")
|
99 |
#llm = AutoModelForCausalLM.from_pretrained("microsoft/Phi-3-mini-128k-instruct", trust_remote_code=True, token=access_token)
|
100 |
#llm = pipeline("text-generation", model="google/gemma-1.1-2b-it")
|
|
|
|
|
|
|
|
|
101 |
|
102 |
pt = ChatPromptTemplate.from_template(prompt_template)
|
103 |
# Retrieve and generate using the relevant snippets of the blog.
|
|
|
15 |
#from transformers import pipeline
|
16 |
# Load model directly
|
17 |
#from transformers import AutoModelForCausalLM
|
18 |
+
from langchain_community.llms.huggingface_pipeline import HuggingFacePipeline
|
19 |
+
|
20 |
|
|
|
21 |
|
22 |
|
|
|
23 |
#access_token = os.getenv("HUGGINGFACE_API_KEY")
|
24 |
|
25 |
|
|
|
91 |
#repo_id='meta-llama/Meta-Llama-3-70B'
|
92 |
#repo_id = 'mistralai/Mixtral-8x7B-Instruct-v0.1'
|
93 |
#repo_id= 'nvidia/Llama3-ChatQA-1.5-8B'
|
94 |
+
#repo_id= 'google/gemma-1.1-2b-it'
|
95 |
+
#llm = HuggingFaceEndpoint(repo_id=repo_id, temperature=0.3,token = HUGGINGFACEHUB_API_TOKEN)
|
96 |
#tokenizer = AutoTokenizer.from_pretrained("google/gemma-1.1-2b-it")
|
97 |
#llm = AutoModelForCausalLM.from_pretrained("google/gemma-1.1-2b-it")
|
98 |
#llm = AutoModelForCausalLM.from_pretrained("microsoft/Phi-3-mini-128k-instruct", trust_remote_code=True, token=access_token)
|
99 |
#llm = pipeline("text-generation", model="google/gemma-1.1-2b-it")
|
100 |
+
llm = HuggingFacePipeline.from_model_id(
|
101 |
+
model_id="Phi-3-mini-128k-instruct",
|
102 |
+
task="text-generation",
|
103 |
+
pipeline_kwargs={"max_new_tokens": 10})
|
104 |
|
105 |
pt = ChatPromptTemplate.from_template(prompt_template)
|
106 |
# Retrieve and generate using the relevant snippets of the blog.
|