boryasbora commited on
Commit
57ec3ad
·
verified ·
1 Parent(s): 65b9327

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -4
app.py CHANGED
@@ -17,9 +17,9 @@ from datetime import date
17
  from transformers import AutoModelForCausalLM, AutoTokenizer
18
 
19
  # Environment variables
20
- # os.environ['LANGCHAIN_TRACING_V2'] = 'true'
21
- # os.environ['LANGCHAIN_ENDPOINT'] = 'https://api.smith.langchain.com'
22
- # os.environ['LANGCHAIN_API_KEY'] = os.environ.get('LANGCHAIN_API_KEY')
23
 
24
 
25
  # Load model and tokenizer
@@ -86,7 +86,15 @@ def get_chain(temperature):
86
  pipe = pipeline("text-generation", model=model_name)
87
 
88
  # Initialize the LangChain HuggingFacePipeline
89
- llm = HuggingFacePipeline(pipeline=pipe)
 
 
 
 
 
 
 
 
90
 
91
  # Initialize LangChain
92
  # llm = HuggingFaceLLM(
 
17
  from transformers import AutoModelForCausalLM, AutoTokenizer
18
 
19
  # Environment variables
20
+ os.environ['LANGCHAIN_TRACING_V2'] = 'true'
21
+ os.environ['LANGCHAIN_ENDPOINT'] = 'https://api.smith.langchain.com'
22
+ os.environ['LANGCHAIN_API_KEY'] = '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'
23
 
24
 
25
  # Load model and tokenizer
 
86
  pipe = pipeline("text-generation", model=model_name)
87
 
88
  # Initialize the LangChain HuggingFacePipeline
89
+ llm = HuggingFacePipeline.from_model_id(
90
+ model_id="microsoft/Phi-3-mini-4k-instruct",
91
+ task="text-generation",
92
+ pipeline_kwargs={
93
+ "max_new_tokens": 100,
94
+ "top_k": 50,
95
+ "temperature": temperature,
96
+ },
97
+ )
98
 
99
  # Initialize LangChain
100
  # llm = HuggingFaceLLM(