boryasbora commited on
Commit
1b3714a
·
verified ·
1 Parent(s): 2ec4111

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -6
app.py CHANGED
@@ -4,7 +4,8 @@ import pickle
4
  from langchain.prompts import ChatPromptTemplate
5
  from langchain.text_splitter import RecursiveCharacterTextSplitter
6
  from langchain_huggingface import HuggingFaceEmbeddings
7
- from huggingface_llm import HuggingFaceLLM
 
8
  from langchain.retrievers import ParentDocumentRetriever
9
  from langchain.storage import InMemoryStore
10
  from langchain_chroma import Chroma
@@ -79,11 +80,17 @@ def get_chain(temperature):
79
  retriever = load_retriever(docstore_path,chroma_path,embeddings,child_splitter,parent_splitter)
80
 
81
  # Replace the local OLMOLLM with the Hugging Face model
82
- llm = HuggingFaceLLM(
83
- model_id="EleutherAI/gpt-neo-1.3B", # or another suitable model
84
- temperature=temperature,
85
- max_tokens=256
86
- )
 
 
 
 
 
 
87
 
88
  today = date.today()
89
  # Response prompt
 
4
  from langchain.prompts import ChatPromptTemplate
5
  from langchain.text_splitter import RecursiveCharacterTextSplitter
6
  from langchain_huggingface import HuggingFaceEmbeddings
7
+ # from huggingface_llm import HuggingFaceLLM
8
+ from langchain import HuggingFaceLLM
9
  from langchain.retrievers import ParentDocumentRetriever
10
  from langchain.storage import InMemoryStore
11
  from langchain_chroma import Chroma
 
80
  retriever = load_retriever(docstore_path,chroma_path,embeddings,child_splitter,parent_splitter)
81
 
82
  # Replace the local OLMOLLM with the Hugging Face model
83
+ model_name = "gpt2"
84
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
85
+ model = AutoModelForCausalLM.from_pretrained(model_name)
86
+
87
+ # Initialize LangChain
88
+ llm = HuggingFaceLLM(model=model, tokenizer=tokenizer)
89
+ # llm = HuggingFaceLLM(
90
+ # model_id="EleutherAI/gpt-neo-1.3B", # or another suitable model
91
+ # temperature=temperature,
92
+ # max_tokens=256
93
+ # )
94
 
95
  today = date.today()
96
  # Response prompt