Downloads · 30 days
10
11% of all-time downloads
ardaorcun/finetuned_cosmos2603
finetuned_cosmos2603 is a text generation model from ardaorcun. Use it when you need the model to write or continue text. It is set up for transformers.
This model is a fine-tuned version of YTU's Cosmos GPT2 Language Model. You can check the code from here:<a href="https://github.com/Stealeristaken/Entry-Mid-Level-AI-Projects/blob/main/Fine%20Tuning%20Cosmos%20by%20L…
Downloads · 30 days
10
11% of all-time downloads
All-time downloads
90
Public
Parameters
774M
4.6 GB on disk
Likes
1
Public
Click a slice to open those files.
.safetensors3.1 GB · 100%
From the Hugging Face model README
This model is a fine-tuned version of YTU's Cosmos GPT2 Language Model. You can check the code from here:<a href="https://github.com/Stealeristaken/Entry-Mid-Level-AI-Projects/blob/main/Fine%20Tuning%20Cosmos%20by%20LoRA%20and%20QLoRA.ipynb">Fine Tuning Cosmos by LoRA and QLoRA</a>
The model was fine-tuned using LoRA and QLoRA techniques. Training parameters are defined below.
For training, I used Merve's Turkish Instructions Dataset, which you can check here: <a href="https://huggingface.co/datasets/merve/turkish_instructions">Merve's Turkish Instructions Dataset</a>
def format_instruction(sample):
return f"""Sen cevap vermeyi seven yardımcı bir dil modelisin.
### Input:
{sample["talimat"]}
### Context:
{sample[" giriş"]}
### Response:
{sample[" çıktı"]}
"""
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
model_id = "ardaorcun/finetuned_cosmos2603"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id,
device_map='auto',
load_in_8bit=True)
sampling_params = dict(do_sample=True, temperature=0.3, top_k=50, top_p=0.9)
pipe = pipeline("text-generation",
model=model,
tokenizer=tokenizer,
device_map="auto",
max_new_tokens=512,
return_full_text=True,
repetition_penalty=1.1
)
DEFAULT_SYSTEM_PROMPT = "Sen cevap vermeyi seven yardımcı bir dil modelisin.\n"
def format_instruction(sample):
return f"""{DEFAULT_SYSTEM_PROMPT}
### Input:
{sample["talimat"]}
### Context:
{sample["giriş"]}
### Response:
{sample["çıktı"]}"""
prompt = "your_prompt"
girdi = "your_entry"
instruction = f"""Sen cevap vermeyi seven yardımcı bir dil modelisin.\n### Input:\n{prompt}\n\n### Context:\n{girdi}\n\n### Response:"""
pipe = pipeline("text-generation", model=model, tokenizer=tokenizer, max_length = 2048)
result = pipe(instruction)
print(result[0]['generated_text'][len(instruction):])