shahidul034 commited on
Commit
3056919
1 Parent(s): ab8541b

End of training

Browse files
Files changed (1) hide show
  1. README.md +53 -80
README.md CHANGED
@@ -1,80 +1,53 @@
1
- # KUET CHATBOT
2
- Contributed by Jesiara Khatun and Sadia Islam (CSE 2K19, KUET)
3
- ```
4
- !pip install peft -q
5
- !pip install transformers[sentencepiece] -q
6
- !pip install sentencepiece
7
- !pip install accelerate
8
- !pip install bitsandbytes
9
- ```
10
-
11
- ```
12
- import torch
13
- from peft import PeftModel
14
- import transformers
15
- import textwrap
16
- from transformers import LlamaTokenizer, LlamaForCausalLM, GenerationConfig
17
- from transformers.generation.utils import GreedySearchDecoderOnlyOutput
18
-
19
- DEVICE = "cuda" if torch.cuda.is_available() else "cpu"
20
- DEVICE
21
- tokenizer = LlamaTokenizer.from_pretrained("meta-llama/Llama-2-7b-hf")
22
-
23
- model = LlamaForCausalLM.from_pretrained(
24
- "abhishek/llama-2-7b-hf-small-shards",
25
- load_in_4bit=True,
26
- device_map="auto",
27
- )
28
-
29
- model = PeftModel.from_pretrained(model, "shahidul034/kuet_chatbot", torch_dtype=torch.float16)
30
- model.config.pad_token_id = tokenizer.pad_token_id = 0 # unk
31
- model.config.bos_token_id = 1
32
- model.config.eos_token_id = 2
33
-
34
- model = model.eval()
35
- model = torch.compile(model)
36
- PROMPT_TEMPLATE = f"""
37
- Below is an instruction that describes a task. Write a response that appropriately completes the request.
38
-
39
- ### Instruction:
40
- [INSTRUCTION]
41
-
42
- ### Response:
43
- """
44
-
45
-
46
- def create_prompt(instruction: str) -> str:
47
- return PROMPT_TEMPLATE.replace("[INSTRUCTION]", instruction)
48
-
49
- # print(create_prompt("What is (are) Glaucoma ?"))
50
-
51
- def generate_response(prompt: str, model: PeftModel) -> GreedySearchDecoderOnlyOutput:
52
- encoding = tokenizer(prompt, return_tensors="pt")
53
- input_ids = encoding["input_ids"].to(DEVICE)
54
-
55
- generation_config = GenerationConfig(
56
- temperature=0.1,
57
- top_p=0.75,
58
- repetition_penalty=1.1,
59
- )
60
- with torch.inference_mode():
61
- return model.generate(
62
- input_ids=input_ids,
63
- generation_config=generation_config,
64
- return_dict_in_generate=True,
65
- output_scores=True,
66
- max_new_tokens=256,
67
- )
68
- def format_response(response: GreedySearchDecoderOnlyOutput) -> str:
69
- decoded_output = tokenizer.decode(response.sequences[0])
70
- response = decoded_output.split("### Response:")[1].strip()
71
- return "\n".join(textwrap.wrap(response))
72
-
73
- def ask_alpaca(prompt: str, model: PeftModel = model) -> str:
74
- prompt = create_prompt(prompt)
75
- response = generate_response(prompt, model)
76
- print(format_response(response))
77
-
78
- ask_alpaca("where is kuet located?")
79
-
80
- ```
 
1
+ ---
2
+ license: apache-2.0
3
+ base_model: TheBloke/Mistral-7B-Instruct-v0.1-GPTQ
4
+ tags:
5
+ - generated_from_trainer
6
+ model-index:
7
+ - name: KUET_information_LLM
8
+ results: []
9
+ ---
10
+
11
+ <!-- This model card has been generated automatically according to the information the Trainer had access to. You
12
+ should probably proofread and complete it, then remove this comment. -->
13
+
14
+ # KUET_information_LLM
15
+
16
+ This model is a fine-tuned version of [TheBloke/Mistral-7B-Instruct-v0.1-GPTQ](https://huggingface.co/TheBloke/Mistral-7B-Instruct-v0.1-GPTQ) on the None dataset.
17
+
18
+ ## Model description
19
+
20
+ More information needed
21
+
22
+ ## Intended uses & limitations
23
+
24
+ More information needed
25
+
26
+ ## Training and evaluation data
27
+
28
+ More information needed
29
+
30
+ ## Training procedure
31
+
32
+ ### Training hyperparameters
33
+
34
+ The following hyperparameters were used during training:
35
+ - learning_rate: 0.0002
36
+ - train_batch_size: 24
37
+ - eval_batch_size: 8
38
+ - seed: 42
39
+ - optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
40
+ - lr_scheduler_type: cosine
41
+ - training_steps: 600
42
+ - mixed_precision_training: Native AMP
43
+
44
+ ### Training results
45
+
46
+
47
+
48
+ ### Framework versions
49
+
50
+ - Transformers 4.36.0.dev0
51
+ - Pytorch 2.1.1+cu121
52
+ - Datasets 2.15.0
53
+ - Tokenizers 0.15.0