File size: 5,035 Bytes
66b59f0
 
1cdeeea
9f890ce
 
 
 
 
 
 
 
 
 
 
 
 
66b59f0
 
1cdeeea
9f890ce
66b59f0
 
 
 
 
9f890ce
66b59f0
9f890ce
 
 
 
 
66b59f0
 
 
 
 
9f890ce
66b59f0
9f890ce
66b59f0
9f890ce
66b59f0
 
 
9f890ce
66b59f0
 
 
9f890ce
66b59f0
 
 
9f890ce
 
 
67aa02d
9f890ce
67aa02d
 
9f890ce
67aa02d
 
66b59f0
67aa02d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9f890ce
66b59f0
 
 
 
 
473f025
 
 
66b59f0
 
 
9f890ce
66b59f0
 
 
17fc029
66b59f0
17fc029
7054660
 
 
 
17fc029
 
7054660
66b59f0
 
9f890ce
66b59f0
9f890ce
66b59f0
 
 
9f890ce
66b59f0
 
 
9f890ce
66b59f0
 
 
9f890ce
66b59f0
 
 
2fee75e
66b59f0
 
 
7054660
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
---
library_name: transformers
tags:
- peft
- trl
- torch
- wandb
- ipex
license: apache-2.0
language:
- en
base_model:
- NousResearch/Llama-2-7b-hf
datasets:
- mlabonne/mini-platypus
pipeline_tag: text-generation
---


# Model Card for Fine-Tuned Llama-2-7b Model

## Model Details

### Model Description

This model is a fine-tuned version of the Llama-2-7b model, specifically adapted for causal language modeling tasks. The fine-tuning utilizes the PEFT (Parameter-Efficient Fine-Tuning) technique with LoRA (Low-Rank Adaptation) to optimize performance while reducing computational costs. The training was conducted using the `mlabonne/mini-platypus` dataset and incorporates features such as integration with W&B for experiment tracking and Intel's Extension for PyTorch (IPEX) for enhanced performance.

- **Developed by:** Md. Jannatul Nayem
- **Model type:** Causal Language Model
- **Language(s) (NLP):** Engish
- **License:** Apache 2.0
- **Finetuned from model :** NousResearch/Llama-2-7b-hf

## Uses

### Direct Use

The model can be utilized for text generation tasks where the generation of coherent and contextually relevant text is required. This includes applications like chatbots, content creation, and interactive storytelling.

### Downstream Use

When fine-tuned, this model can serve in larger ecosystems for tasks like personalized dialogue systems, question answering, and other natural language understanding applications.

### Out-of-Scope Use

The model is not intended for use in generating harmful or misleading content, and users should exercise caution to prevent misuse in sensitive areas such as misinformation or hate speech.

### Recommendations

Users should consider implementing bias mitigation strategies and ensure thorough evaluation of the model's outputs, especially in sensitive applications.

## How to Get Started with the Model

Use the following code snippet to get started with loading and using the model:

```python
# Import necessary libraries
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
import intel_extension_for_pytorch as ipex  # Optional for Intel optimization

# Specify your Hugging Face model repository
hf_model = "nayem-ng/mdjannatulnayem_llama2_7b_finetuned_casuallm_lora"

# Load the fine-tuned model and tokenizer
model = AutoModelForCausalLM.from_pretrained(hf_model)
tokenizer = AutoTokenizer.from_pretrained(hf_model)

# Move the model to the desired device
device = "cuda" if torch.cuda.is_available() else "cpu"
model.to(device)

# Set the model to evaluation mode
model.eval()

# Optional: Optimize with Intel extensions for PyTorch
# Uncomment the next line if you want to use Intel optimizations
# model = ipex.optimize(model)

# Function to generate text
def generate_text(prompt, max_length=50):
    # Tokenize the input prompt
    inputs = tokenizer(prompt, return_tensors="pt").to(device)

    # Generate output
    with torch.no_grad():
        outputs = model.generate(**inputs, max_length=max_length)

    # Decode and return the generated text
    return tokenizer.decode(outputs[0], skip_special_tokens=True)

# Example usage
if __name__ == "__main__":
    prompt = "Once upon a time"
    generated_text = generate_text(prompt)
    print("Generated Text:", generated_text)
```

## Training Details

### Training Data

The model was fine-tuned using the mlabonne/mini-platypus dataset, which consists of diverse text inputs designed to enhance the model's capabilities in conversational settings.

[mlabonne/mini-platypus](https://huggingface.co/datasets/mlabonne/mini-platypus)

### Training Procedure

The training utilized a supervised fine-tuning procedure with the following hyperparameters:

#### Training Hyperparameters

The model was trained using bfloat16 (bf16) mixed precision, which allows for faster training times and reduced memory usage compared to traditional fp32 (float32). This precision format is particularly beneficial when working with large models, as it helps to maintain numerical stability while optimizing performance on compatible hardware.

- Training regime: bf16 mixed precision
- Number of epochs: 1
- Batch size: 10
- Warmup steps: 10
- Gradient accumulation steps: 1
- Learning rate: 2e-4
- Warmup steps: 10
- Evaluation strategy: Evaluations are performed every 1000 steps to monitor the model's performance during training.


## Model Examination

Further interpretability studies can be conducted to understand decision-making processes within the model's responses.

### Model Architecture and Objective

The model is based on the Transformer architecture, specifically designed for Causal Language Modeling (CLM).

### Compute Infrastructure

Intel® Tiber™ AI Cloud

#### Hardware

Intel(R) Xeon(R) Platinum 8480+

#### Software

PyTorch, Transformers Library (from Hugging Face),PEFT, TRL, WandB, Intel Extension for PyTorch (IPEX)

## Model Card Contact

🤖 Md. Jannatul nayem | [Mail](nayemalimran106@gmail.com) | [LinkedIn](https://www.linkedin.com/in/md-jannatul-nayem)