min24ss commited on
Commit
b92d5fd
·
verified ·
1 Parent(s): 86ff856

Update r-story-test.py

Browse files
Files changed (1) hide show
  1. r-story-test.py +4 -4
r-story-test.py CHANGED
@@ -78,7 +78,6 @@ print("\n최종 문장 수:", len(texts))
78
 
79
  # In[6]:
80
 
81
-
82
  from langchain.vectorstores import FAISS
83
  from langchain.embeddings import HuggingFaceEmbeddings
84
 
@@ -118,7 +117,7 @@ from transformers import pipeline
118
  generator = pipeline(
119
  "text-generation",
120
  model="kakaocorp/kanana-nano-2.1b-instruct",
121
- device=0
122
  )
123
 
124
 
@@ -139,9 +138,10 @@ vectorstore = FAISS.load_local("solo_leveling_faiss_ko", embedding_model, allow_
139
 
140
  model_name = "kakaocorp/kanana-nano-2.1b-instruct"
141
  tokenizer = AutoTokenizer.from_pretrained(model_name)
142
- model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.float16).to("cuda")
 
143
 
144
- llm_pipeline = pipeline("text-generation", model=model, tokenizer=tokenizer, max_new_tokens=256)
145
  llm = HuggingFacePipeline(pipeline=llm_pipeline)
146
 
147
  custom_prompt = PromptTemplate(
 
78
 
79
  # In[6]:
80
 
 
81
  from langchain.vectorstores import FAISS
82
  from langchain.embeddings import HuggingFaceEmbeddings
83
 
 
117
  generator = pipeline(
118
  "text-generation",
119
  model="kakaocorp/kanana-nano-2.1b-instruct",
120
+ device= -1
121
  )
122
 
123
 
 
138
 
139
  model_name = "kakaocorp/kanana-nano-2.1b-instruct"
140
  tokenizer = AutoTokenizer.from_pretrained(model_name)
141
+ model = AutoModelForCausalLM.from_pretrained(
142
+ model_name, torch_dtype=torch.float32).to("cpu")
143
 
144
+ llm_pipeline = pipeline("text-generation", model=model, tokenizer=tokenizer, max_new_tokens=128)
145
  llm = HuggingFacePipeline(pipeline=llm_pipeline)
146
 
147
  custom_prompt = PromptTemplate(