Schmadge commited on
Commit
51a1dc6
·
1 Parent(s): eb022a3

add readme

Browse files
Files changed (1) hide show
  1. README.md +61 -0
README.md ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Instruction-Tuned Mamba 2.8B on SlimOrca Dataset
2
+
3
+ ## Overview
4
+ This repository features the [2.8 billion parameter Mamba model](https://huggingface.co/state-spaces/mamba-2.8b), fine-tuned on a subset (20k) of the [SlimOrca dataset](https://huggingface.co/datasets/Open-Orca/SlimOrca). Big thanks to Justin Mattern from Haven for contributing essential code in the [mamba-chat repository](https://github.com/havenhq/mamba-chat)
5
+
6
+
7
+ ## Usage Instructions
8
+ To utilize the fine-tuned model, follow the Python code snippet below:
9
+
10
+ ```python
11
+ import torch
12
+ from transformers import AutoTokenizer
13
+ from mamba_ssm.models.mixer_seq_simple import MambaLMHeadModel
14
+
15
+ device = "cuda"
16
+ tokenizer = AutoTokenizer.from_pretrained("Schmadge/mamba-slim-orca")
17
+ tokenizer.eos_token = tokenizer.pad_token = "<|endoftext|>"
18
+ tokenizer.chat_template = AutoTokenizer.from_pretrained("HuggingFaceH4/zephyr-7b-beta").chat_template
19
+ model = MambaLMHeadModel.from_pretrained("Schmadge/mamba-slim-orca", device=device, dtype=torch.float16)
20
+
21
+ def generate_response(system_prompt, user_prompt):
22
+ # Preparing the prompt
23
+ prompt = [
24
+ {"role": "system", "content": system_prompt},
25
+ {"role": "user", "content": user_prompt}
26
+ ]
27
+ input_ids = tokenizer.apply_chat_template(prompt, return_tensors="pt", add_generation_prompt=True).to(device)
28
+
29
+ # Generating the response
30
+ out = model.generate(input_ids=input_ids, max_length=2000, temperature=0.3, top_p=0.7, eos_token_id=tokenizer.eos_token_id)
31
+ decoded = tokenizer.batch_decode(out)
32
+
33
+ return decoded[0].split("<|assistant|>\n")[-1].replace('<|endoftext|>','')
34
+
35
+ system_prompt = "You are an AI assistant. Provide a detailed answer so user don't need to search outside to understand the answer."
36
+ user_prompt = "In a room I have only 3 sisters. Anna is reading a book. Alice is playing a match of chess.What the third sister, Amanda is doing ?"
37
+ response = generate_response(system_prompt, user_prompt)
38
+ print(response)
39
+ ```
40
+
41
+ ## Citation
42
+ Mamba:
43
+ ```bibtex
44
+ @article{mamba,
45
+ title={Mamba: Linear-Time Sequence Modeling with Selective State Spaces},
46
+ author={Gu, Albert and Dao, Tri},
47
+ journal={arXiv preprint arXiv:2312.00752},
48
+ year={2023}
49
+ }
50
+ ```
51
+
52
+ SlimOrca:
53
+ ```bibtex
54
+ @misc{SlimOrca,
55
+ title = {SlimOrca: An Open Dataset of GPT-4 Augmented FLAN Reasoning Traces, with Verification},
56
+ author = {Wing Lian and others},
57
+ year = {2023},
58
+ publisher = {HuggingFace},
59
+ url = {https://huggingface.co/Open-Orca/SlimOrca}
60
+ }
61
+ ```