|
import os |
|
import torch |
|
from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline |
|
from langchain_huggingface.llms import HuggingFacePipeline |
|
|
|
''' |
|
AutoModelForCausalLm์ ์ฌ์ฉํ์ฌ ๋ชจ๋ธ ๋ถ๋ฌ์ค๊ธฐ |
|
|
|
์๋๊ฐ ๋๋ฆฐํธ์ ์ํ๋ ๋ฌธ์ ์์ด ๋์๊ฐ ์ ์๋ ์์ ์ ์ธ ๋ฐฉ์ |
|
''' |
|
def load_Auto(): |
|
model_id = 'Dongwookss/small_fut_final' |
|
tokenizer = AutoTokenizer.from_pretrained(model_id) |
|
model = AutoModelForCausalLM.from_pretrained( |
|
model_id, |
|
torch_dtype=torch.bfloat16, |
|
device_map="auto", |
|
) |
|
|
|
pipe = pipeline( |
|
"text-generation", |
|
model=model, |
|
tokenizer=tokenizer, |
|
max_new_tokens=2048, |
|
) |
|
|
|
llm = HuggingFacePipeline( |
|
pipeline=pipe, |
|
model_kwargs={"temperature": 0.7}, |
|
) |
|
return llm |