|
--- |
|
base_model: unsloth/gemma-2-2b-it |
|
library_name: peft |
|
--- |
|
|
|
## Model Summary |
|
|
|
This model is fine-tuned from gemma-2-2b-it using a thinking dataset meticulously crafted by our team, aiming to enhance the model's ability to solve complex, sequential problems through step-by-step logical thinking. |
|
|
|
## Motivation |
|
|
|
Reasoning is a cornerstone of effective problem-solving, yet many of the models trained for this task are quite large and too heavy for everyday usage, particularly when their extra long responses considered. To address this, we developed a reasoning-focused compact language model (LLM) capable of structured thinking, self-reflection, and iterative problem-solving. Our goal is to create a model that not only excels in reasoning tasks but also operates efficiently for broader accessibility. |
|
|
|
## Usage |
|
|
|
```python |
|
|
|
from unsloth import FastLanguageModel |
|
import torch |
|
from transformers import TextStreamer |
|
|
|
|
|
max_seq_length = 3072 |
|
dtype = None |
|
load_in_4bit = False |
|
lora_path = "/altaidevorg/gemma-altai-2-2b-reasoning" |
|
use_streamer = False |
|
|
|
model, tokenizer = FastLanguageModel.from_pretrained( |
|
model_name=lora_path, |
|
max_seq_length=max_seq_length, |
|
dtype=dtype, |
|
load_in_4bit=load_in_4bit, |
|
) |
|
FastLanguageModel.for_inference(model) |
|
|
|
text_streamer = TextStreamer(tokenizer, skip_prompt = True) |
|
) |
|
|
|
messages = [ |
|
{"role": "user", "content": user_prompt}, |
|
] |
|
|
|
|
|
input_ids = tokenizer.apply_chat_template( |
|
messages, |
|
tokenize = True, |
|
add_generation_prompt = True, |
|
return_tensors = "pt", |
|
).cuda() |
|
|
|
terminators = [tokenizer.eos_token_id, tokenizer.convert_tokens_to_ids("<end_of_turn>")] |
|
|
|
outputs = model.generate(input_ids = input_ids, |
|
streamer = text_streamer if use_streamer else None, |
|
max_new_tokens = 1024, |
|
eos_token_id=terminators, |
|
use_cache=True, do_sample=True, temperature=0.6, top_p=0.9) |
|
if not use_streamer: |
|
out = outputs[0][input_ids.shape[-1]:] |
|
generated_text = tokenizer.decode(out, skip_special_tokens=True) |
|
print(generated_text) |
|
|
|
|
|
``` |
|
|
|
|
|
## Dataset |
|
|
|
The dataset was prepared through a comprehensive process based on our open-source reasoning and thinking dataset collection method. We curated and refined existing open-source datasets focusing on logical reasoning, critical thinking, and problem-solving. These datasets were preprocessed and structured for fine-tuning large language models to ensure high-quality outputs. |
|
The dataset will be made publicly available through its dedicated repository [altaidevorg/thinking-dataset-en](https://huggingface.co/datasets/altaidevorg/thinking-dataset-en). |
|
|
|
|