File size: 3,590 Bytes
9ce7c25
741a805
101e210
 
 
 
 
 
 
 
 
 
 
 
9ce7c25
741a805
101e210
741a805
101e210
156d629
101e210
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
741a805
 
 
 
 
 
 
 
 
 
 
 
101e210
 
 
 
 
 
 
 
 
cd9fdc6
101e210
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
library_name: peft
license: llama2
datasets:
- TuningAI/Startups_V2
language:
- en
pipeline_tag: conversational
tags:
- law
- startups
- finance
- tax
- Algerian
---

## Model Name: **Llama2_13B_startup_Assistant**

## Description:

Llama2_13B_startup_Assistant is a highly specialized language model fine-tuned from Meta's Llama2_13B. 
It has been tailored to assist with inquiries related to Algerian startups, offering valuable insights and guidance in these domains.

## Base Model: 
This model is based on the Meta's **meta-llama/Llama-2-13b-chat-hf** architecture, 
making it a highly capable foundation for generating human-like text responses.

## Dataset :
This model was fine-tuned on a custom dataset meticulously curated with more than 200 unique examples.
The dataset incorporates both manual entries and contributions from GPT3.5, GPT4, and Falcon 180B models.

## Fine-tuning Techniques:
Fine-tuning was performed using QLoRA (Quantized LoRA), an extension of LoRA that introduces quantization for enhanced parameter efficiency.
The model benefits from 4-bit NormalFloat (NF4) quantization and Double Quantization techniques, ensuring optimized performance.

## Performance:
**Llama2_13B_startup_Assistant** exhibits improved performance and efficiency in addressing queries related to Algerian tax law and startups,
making it a valuable resource for individuals and businesses navigating these areas.

## Limitations:

* While highly specialized, this model may not cover every nuanced aspect of Algerian tax law or the startup ecosystem.
* Accuracy may vary depending on the complexity and specificity of questions.
* It may not provide legal advice, and users should seek professional consultation for critical legal matters.

## Training procedure
The following `bitsandbytes` quantization config was used during training:
- load_in_8bit: False
- load_in_4bit: True
- llm_int8_threshold: 6.0
- llm_int8_skip_modules: None
- llm_int8_enable_fp32_cpu_offload: False
- llm_int8_has_fp16_weight: False
- bnb_4bit_quant_type: nf4
- bnb_4bit_use_double_quant: False
- bnb_4bit_compute_dtype: float16
### Framework versions
- PEFT 0.4.0
```
! huggingface-cli login
```
```python
from transformers import pipeline
from transformers import AutoTokenizer
from peft import PeftModel, PeftConfig
from transformers import AutoModelForCausalLM , BitsAndBytesConfig
import torch

#config = PeftConfig.from_pretrained("ayoubkirouane/Llama2_13B_startup_hf")
bnb_config = BitsAndBytesConfig(
    load_in_4bit=True,
    bnb_4bit_quant_type="nf4",
    bnb_4bit_compute_dtype=getattr(torch, "float16"),
    bnb_4bit_use_double_quant=False)
model = AutoModelForCausalLM.from_pretrained(
        "meta-llama/Llama-2-7b-hf",
        quantization_config=bnb_config,
        device_map={"": 0})
model.config.use_cache = False
model.config.pretraining_tp = 1
model = PeftModel.from_pretrained(model, "TuningAI/Llama2_7B_Cover_letter_generator")
tokenizer = AutoTokenizer.from_pretrained("meta-llama/Llama-2-7b-hf" , trust_remote_code=True)
tokenizer.pad_token = tokenizer.eos_token
tokenizer.padding_side = "right"
Instruction = "Given a user's information about the target job, you will generate a Cover letter for this job based on this information."
while 1:
  input_text = input(">>>")
  logging.set_verbosity(logging.CRITICAL)
  prompt = f"### Instruction\n{Instruction}.\n ###Input \n\n{input_text}. ### Output:"
  pipe = pipeline(task="text-generation", model=model, tokenizer=tokenizer,max_length=400)
  result = pipe(prompt)
  print(result[0]['generated_text'].replace(prompt, ''))
```