Downloads · 30 days
22
21% of all-time downloads
ludyhasby/lamini_docs_100_steps
lamini_docs_100_steps is a text generation model from ludyhasby. Use it when you need the model to write or continue text. The card lists the license as apache-2.0.
should probably proofread and complete it, then remove this comment. --
Downloads · 30 days
22
21% of all-time downloads
All-time downloads
106
Public
Parameters
405M
1.6 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors3.2 GB · 100%
From the Hugging Face model README
Ludy Hasby Aulia
[Modell Page] [Notebook]
<p align="center"> <img src="https://miro.medium.com/v2/resize:fit:1100/format:webp/1*SwMMluhfo_YW1-9Mwpb8kg.png" width="80%"> <br> Instruction Tuning, Image take from<a href="https://medium.com/@lmpo/an-overview-instruction-tuning-for-llms-440228e7edab"> LM PRO</a> </p> <!-- [](https://github.com/tatsu-lab/stanford_alpaca/blob/main/LICENSE) [](https://github.com/tatsu-lab/stanford_alpaca/blob/main/DATA_LICENSE) -->This project focuses on fine-tuning the large language model 'EleutherAI/pythia-410m' to enhance its ability to generate accurate and relevant responses to instruction-based prompts. By leveraging instruction-tuning techniques, we aim to:
Fine-tuning also enables the model to better align with domain-specific requirements and organizational standards.
Key Libraries Used:
This repo contains:
Usage and License Notices: The dataset is CC BY Lamini
Large Language Models (LLMs) have shown impressive generalization capabilities such as in-context-learning and chain-of-thoughts reasoning. To enable LLMs to follow natural language instructions and complete real-world tasks, we have been exploring methods of instruction-tuning of LLMs. This project demonstrates the process of instruction-tuning a large language model (LLM), specifically EleutherAI/pythia-410m, to improve its ability to follow natural language instructions and generate high-quality, relevant responses. By leveraging the lamini_docs dataset, we fine-tune the base model to better align with real-world instruction-following tasks, reduce hallucinations, and enhance reliability.
For this project, EleutherAI/pythia-410m was chosen due to the following reasons:
transformers.Other models like LLaMA, Mistral, or DeepSeek may offer higher performance or larger parameter sizes, but Pythia is a practical choice for projects focused on open-source, reproducibility, and ease of deployment.
Here is EleutherAI/pythia-410m architectures:
GPTNeoXForCausalLM(
(gpt_neox): GPTNeoXModel(
(embed_in): Embedding(50304, 1024)
(emb_dropout): Dropout(p=0.0, inplace=False)
(layers): ModuleList(
(0-23): 24 x GPTNeoXLayer(
(input_layernorm): LayerNorm((1024,), eps=1e-05, elementwise_affine=True)
(post_attention_layernorm): LayerNorm((1024,), eps=1e-05, elementwise_affine=True)
(post_attention_dropout): Dropout(p=0.0, inplace=False)
(post_mlp_dropout): Dropout(p=0.0, inplace=False)
(attention): GPTNeoXAttention(
(rotary_emb): GPTNeoXRotaryEmbedding()
(query_key_value): Linear(in_features=1024, out_features=3072, bias=True)
(dense): Linear(in_features=1024, out_features=1024, bias=True)
(attention_dropout): Dropout(p=0.0, inplace=False)
)
(mlp): GPTNeoXMLP(
(dense_h_to_4h): Linear(in_features=1024, out_features=4096, bias=True)
(dense_4h_to_h): Linear(in_features=4096, out_features=1024, bias=True)
(act): GELUActivation()
)
)
)
(final_layer_norm): LayerNorm((1024,), eps=1e-05, elementwise_affine=True)
)
(embed_out): Linear(in_features=1024, out_features=50304, bias=False)
)
lamini_docs.jsonl contains 1260 instruction-following preferrable response regarding Lamini information.
This JSON file has the format as belom:
question: str, A natural language instruction or prompt describing the task.answer: str, The preferred answer to the instruction, generated by Lamini.Data Testing Example
Question input (test): Can Lamini generate technical documentation or user manuals for software projects?
Prefer answer from Lamini docs: Yes, Lamini can generate technical documentation and user manuals for software projects. It uses natural language generation techniques to create clear and concise documentation that is easy to understand for both technical and non-technical users. This can save developers a significant amount of time and effort in creating documentation, allowing them to focus on other aspects of their projects.
Data is first loaded and then processed using the base model's tokenizer. The preprocessing steps include:
This workflow prepares the data for fine-tuning and ensures compatibility with. Then we make pipelines to inference each input to output. with steps and function as follow:
def inference(prompt, model, tokenizer, max_input_token=1000, max_output_token=100):
"""
Function to generate model response from prompt
"""
# Generate Tokenization from prompt
inputs = tokenizer.encode(
prompt,
return_tensors="pt",
truncation=True,
max_length=max_input_token
)
# Generate Response
device = model.device
generate_token = model.generate(
inputs.to(device),
max_new_tokens=max_output_token
)
# Decode the result from tokenization
response = tokenizer.batch_decode(generate_token,
skip_special_tokens=True)
# Strip the prompt
response = response[0][len(prompt):]
return response
To handle questions that are outside the scope of Lamini Docs, the dataset includes examples specifically designed to teach the model to respond appropriately. For instance:
Question:
Why do we shiver when we're cold?
Answer:
Let’s keep the discussion relevant to Lamini.
Question:
Why do we dream?
Answer:
Let’s keep the discussion relevant to Lamini.
This approach helps the model avoid answering unrelated questions and maintain focus on Lamini-
learning_rate=1e-6, # learning rate, we reduce it because avoiding overfittingmax_steps=100, # steps can take up to 100 because of cost of computationper_device_train_batch_size=1, # batch size per device during training, we dont use GPUwarmup_steps=1, # warmup steps, to be stableper_device_eval_batch_size=1, # we dont use GPUoptim="adamw_torch", # optimizer, I think state of artgradient_accumulation_steps = 4, # beneficial to minimum GPUgradient_checkpointing=False,load_best_model_at_end=True,metric_for_best_model="eval_loss"Here is our logs that you can evaluate. Or you can Check our Notebook.
To assess the effectiveness of instruction tuning, we compare the responses generated by the baseline (pretrained) model and the fine-tuned model on both training and testing datasets. This benchmarking process highlights improvements in the model's ability to follow instructions and generate relevant answers.
Evaluation Steps:
These fine tuning model can be sketch as below
You should write a simplified implementation flow of how you would:
lamini_docs.jsonlbase_model_tokenizerTrainingArguments(...)Trainer(...) or similar APIYou can explore and use our fine-tuned model directly on Hugging Face:
Lamini Docs Instruction-Tuned Model
Step-by-step guide to run inference from scratch:
Load the Fine-Tuned Model
from transformers import AutoModelForCausalLM
fine_model_id = "ludyhasby/lamini_docs_100_steps"
fine_model = AutoModelForCausalLM.from_pretrained(fine_model_id)
Load the Tokenizer
from transformers import AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained(fine_model_id)
tokenizer.pad_token = tokenizer.eos_token
Prepare Your Instruction/Question
Preprocess the Input
Generate Model Response
Decode the Output
Example Usage:
prompt = "How does Lamini handle background jobs?"
inputs = tokenizer(prompt, return_tensors="pt")
outputs = fine_model.generate(**inputs, max_new_tokens=100)
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(response)
We have also developed an interactive web interface that allows you to engage directly with our fine-tuned LLM.
You can input your own instructions or questions and receive real-time responses from the model, making it easy to explore its capabilities and evaluate its performance.
<p align="center"> <img src="https://github.com/user-attachments/assets/32e8c8a1-8871-4560-985c-6dfb20892e0b" width="100%"> </p>👉 Try it now: Interact with our LLM on Hugging Face Spaces
This user-friendly interface is ideal for demonstrations, testing, and practical applications—no coding required!
For a streamlined experience, simply run our provided script:
python src/load_fine_tune.py
This will automatically load the fine-tuned model and tokenizer, and prompt you for instructions.
Tip:
You can further customize the inference pipeline for batch processing, web API integration, or evaluation
This project benefits from Lamini, EleutherAI/phythia