Spaces:
Sleeping
Sleeping
AjithBharadwaj
commited on
Commit
•
dd36b8a
1
Parent(s):
82170b9
Update app.py
Browse files
app.py
CHANGED
@@ -3,7 +3,7 @@ from langchain.chains import LLMChain
|
|
3 |
from langchain_core.prompts import PromptTemplate
|
4 |
from langchain_community.llms.huggingface_pipeline import HuggingFacePipeline
|
5 |
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline,BitsAndBytesConfig
|
6 |
-
quants = BitsAndBytesConfig(load_in_4bit=True)
|
7 |
|
8 |
template = ''' You are an expert Blog generator , Given the Topic , the intended audience and the maximum number of words ,
|
9 |
Write a blog on the given topic
|
@@ -40,8 +40,8 @@ def main():
|
|
40 |
|
41 |
if st.sidebar.button("Generate Blog"):
|
42 |
model_id = "mistralai/Mistral-7B-Instruct-v0.2"
|
43 |
-
tokenizer = AutoTokenizer.from_pretrained(model_id
|
44 |
-
model = AutoModelForCausalLM.from_pretrained(model_id
|
45 |
pipe = pipeline("text-generation", model=model, tokenizer=tokenizer,max_new_tokens=1000)
|
46 |
hf = HuggingFacePipeline(pipeline=pipe)
|
47 |
chain = LLMChain(llm=hf,prompt=prompt,verbose=True)
|
|
|
3 |
from langchain_core.prompts import PromptTemplate
|
4 |
from langchain_community.llms.huggingface_pipeline import HuggingFacePipeline
|
5 |
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline,BitsAndBytesConfig
|
6 |
+
# quants = BitsAndBytesConfig(load_in_4bit=True)
|
7 |
|
8 |
template = ''' You are an expert Blog generator , Given the Topic , the intended audience and the maximum number of words ,
|
9 |
Write a blog on the given topic
|
|
|
40 |
|
41 |
if st.sidebar.button("Generate Blog"):
|
42 |
model_id = "mistralai/Mistral-7B-Instruct-v0.2"
|
43 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
44 |
+
model = AutoModelForCausalLM.from_pretrained(model_id)
|
45 |
pipe = pipeline("text-generation", model=model, tokenizer=tokenizer,max_new_tokens=1000)
|
46 |
hf = HuggingFacePipeline(pipeline=pipe)
|
47 |
chain = LLMChain(llm=hf,prompt=prompt,verbose=True)
|