Instructions to use Jiminiya/gemma_with_LoRA_OS with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Local Apps Settings
- Unsloth Desktop
unsloth/gemma-7b-bnb-4bit ์ฌ์ฉ
''' from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
๋ณํฉ๋ ๋ชจ๋ธ ๋ค์ด๋ก๋ (LoRA ์์ด๋ ๋ฐ๋ก ์ฌ์ฉ ๊ฐ๋ฅ)
model_name = "Jiminiya/G_os_lora_merged"
ํ ํฌ๋์ด์ ๋ก๋
tokenizer = AutoTokenizer.from_pretrained(model_name)
๋ชจ๋ธ ๋ก๋ (์ด์ PeftModel์ด ํ์ ์์)
model = AutoModelForCausalLM.from_pretrained( model_name, torch_dtype="auto", device_map="auto" )
ํ ์คํธ ์์ฑ ํ์ดํ๋ผ์ธ
pipe = pipeline( "text-generation", model=model, tokenizer=tokenizer, torch_dtype="auto" )
๐ฅ ์ถ๋ก ํจ์ (๊ณ ์ ๋ ์ง์๋ฌธ ์ถ๊ฐ ํฌํจ)
DEFAULT_INSTRUCTION = "Only include an answer. Do not add any additional questions or explanations."
def infer(prompt, max_new_tokens=200): """ ํ๋กฌํํธ์ ์๋์ผ๋ก ์ง์๋ฌธ ์ถ๊ฐํ์ฌ ์คํ """ full_prompt = f"{prompt} {DEFAULT_INSTRUCTION}"
result = pipe(
full_prompt,
max_new_tokens=max_new_tokens,
do_sample=True,
temperature=0.3, # ๐น ์ ํ๋๋ฅผ ๋์ด๊ธฐ ์ํด ๋ฎ์ถค
top_k=50,
top_p=0.9
)
return result[0]["generated_text"]
๐ ํ ์คํธ ์์ (๋ช ํํ ํ๋กฌํํธ ์ฌ์ฉ)
prompt_text = "Explain virtual memory in operating systems." generated_text = infer(prompt_text)
print("Generated Output:\n", generated_text)
'''
- Downloads last month
- 11