KunalThakare279 commited on
Commit
d12f5b4
·
verified ·
1 Parent(s): adfee62

Update llm.py

Browse files
Files changed (1) hide show
  1. llm.py +14 -6
llm.py CHANGED
@@ -1,4 +1,5 @@
1
  from langchain_huggingface.llms import HuggingFacePipeline
 
2
  from langchain import HuggingFaceHub
3
  from huggingface_hub import login
4
  import random
@@ -19,12 +20,19 @@ text = """
19
  """
20
 
21
  print("loading model")
22
- model = HuggingFacePipeline.from_model_id(
23
- model_id="mistralai/Mistral-7B-Instruct-v0.3",
24
- task="text-generation",
25
- pipeline_kwargs={"temperature":1, "max_length":1000,
26
- "repetition_penalty":1.25, "max_new_tokens": 2000}
27
- )
 
 
 
 
 
 
 
28
  print("loading model done!")
29
 
30
  print(model("if 2x = 4 + 10 what will be x"))
 
1
  from langchain_huggingface.llms import HuggingFacePipeline
2
+ from transformers import pipeline
3
  from langchain import HuggingFaceHub
4
  from huggingface_hub import login
5
  import random
 
20
  """
21
 
22
  print("loading model")
23
+ # model = HuggingFacePipeline.from_model_id(
24
+ # model_id="mistralai/Mistral-7B-Instruct-v0.3",
25
+ # task="text-generation",
26
+ # pipeline_kwargs={"temperature":1, "max_length":1000,
27
+ # "repetition_penalty":1.25, "max_new_tokens": 2000}
28
+ # )
29
+
30
+ model = pipeline("text-generation",
31
+ model="mistralai/Mistral-7B-v0.1",
32
+ tokenizer="mistralai/Mistral-7B-v0.1",
33
+ device_map="auto", # Adjust if GPU is available
34
+ torch_dtype="auto")
35
+
36
  print("loading model done!")
37
 
38
  print(model("if 2x = 4 + 10 what will be x"))