Safetensors
llama
File size: 3,636 Bytes
71857e3
 
 
 
96225c6
71857e3
 
 
 
 
 
 
 
 
 
 
 
 
 
96225c6
71857e3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a1b692e
71857e3
 
 
 
 
 
 
 
 
 
 
 
 
 
a1b692e
71857e3
 
 
 
 
 
 
 
 
 
8aec3a8
71857e3
 
 
 
 
8aec3a8
71857e3
 
 
 
 
 
 
 
 
 
 
96225c6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
---
license: apache-2.0
datasets:
- HuggingFaceFW/fineweb-edu
- yahma/alpaca-cleaned
---

# DMaS-LLaMa-Lite-step-43.5k-instruct

This repository provides access to **DMaS-LLaMa-Lite-step-43.5k-instruct**, an instruction fine-tuned version of the DMaS-LLaMa-Lite model. Based on the **43,500-step checkpoint**, this model has been further fine-tuned on question-answering datasets to enable instruction-following and dialogue capabilities. 

It serves as a demonstration of the potential to fine-tune a pretrained LLaMa-based model for downstream tasks, such as question-answering, with improved alignment for human-like responses.

## Model Overview

- **Base Model**: [DMaS-LLaMa-Lite-step-43.5k](https://huggingface.co/McGill-DMaS/DMaS-LLaMa-Lite-step-43.5k)
- **Architecture**: LLaMa-based
- **Parameters**: 1.7B (36 layers, 32 attention heads, RMSNorm)
- **Tokenizer**: GPT-2 tokenizer
- **Fine-tuning Data**: [yahma/alpaca-cleaned](https://huggingface.co/datasets/yahma/alpaca-cleaned)
- **Chat Template**: Follows Vicuna 1.1 format
- **Response End**: Machine answers are terminated with `<|endoftext|>`
- **Objective**: Fine-tune the pretrained model to improve alignment with user instructions and dialogue-based question answering

This model showcases how a LLaMa-based pretrained checkpoint can be effectively adapted for instruction-following tasks, resulting in coherent, relevant, and contextually grounded completions.

## Key Features

- **Instruction Fine-tuning**: Demonstrates alignment to question-answering and dialogue tasks.
- **Chat Template Compatibility**: Compatible with Vicuna 1.1-style formatting, ensuring easy integration with chat-based applications.
- **Early Demonstration**: Highlights the feasibility of fine-tuning pretrained models with minimal downstream data.

## Chat Template

The model follows the Vicuna 1.1 chat format:

```text
A chat between a curious user and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the user's questions.

USER: {user input}
ASSISTANT:{machine response}<|endoftext|>
```

## Usage

You can load and use the model with Hugging Face's Transformers library:

```python
from transformers import AutoModelForCausalLM, AutoTokenizer

model_name = "McGill-DMaS/DMaS-LLaMa-Lite-step-43.5k-instruct"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(model_name)

# Define the prompt in Vicuna 1.1 format
prompt = "A chat between a curious user and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the user's questions.\n\nUSER: What are the Pyramids of Giza known for?\nASSISTANT:"
inputs = tokenizer(prompt, return_tensors="pt")
outputs = model.generate(**inputs, max_length=100)

# Decode the machine response
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(response)
```

## Citation

If you use this model or its training insights in your work, please cite the following [paper](https://arxiv.org/abs/2412.13335):

```bibtex
@article{li2024effectiveness,
  title={Experience of Training a 1.7B-Parameter LLaMa Model From Scratch},
  author={Li, Miles Q and Fung, Benjamin and Huang, Shih-Chia},
  journal={arXiv preprint arXiv:2412.13335},
  year={2024}
}
```

## License

This model and code are released under the **Apache License 2.0**. Please check the respective repositories for detailed terms.

## Training Code

For details on pre-training processes, the scripts are available at:  
📄 **[DMaS-LLaMa-Lite Training Code](https://github.com/McGill-DMaS/DMaS-LLaMa-Lite-Training-Code)**