Core ML
English
TKDKid1000 commited on
Commit
51b1d1f
•
1 Parent(s): 9a77819

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +95 -0
README.md ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ datasets:
4
+ - cerebras/SlimPajama-627B
5
+ - bigcode/starcoderdata
6
+ - OpenAssistant/oasst_top1_2023-08-25
7
+ language:
8
+ - en
9
+ tags:
10
+ - coreml
11
+ ---
12
+
13
+ # TinyLlama-1.1B-Chat-v0.3-CoreML
14
+
15
+ - Model creator: [Zhang Peiyuan](https://huggingface.co/PY007)
16
+ - Original model: [TinyLlama-1.1B-Chat-v0.3](https://huggingface.co/PY007/TinyLlama-1.1B-Chat-v0.3)
17
+
18
+ ## Description
19
+
20
+ This repository contains CoreML model files for [Zhang Peiyuan's TinyLlama-1.1B-Chat-v0.3](https://huggingface.co/PY007/TinyLlama-1.1B-Chat-v0.3).
21
+
22
+ ### About CoreML
23
+
24
+ CoreML is the Apple-exclusive model format that is highly optimized for their Apple Silicon chips and for use with their mobile devices.
25
+
26
+ ## Prompt template: ChatML
27
+
28
+ ```
29
+ <|im_start|>system
30
+ {system_prompt}<|im_end|>
31
+ <|im_start|>user
32
+ {prompt}<|im_end|>
33
+ <|im_start|>assistant
34
+ ```
35
+
36
+ ## Licensing
37
+
38
+ The creator of the source model has listed its license as `apache-2.0`, and this model has therefore used that same license.
39
+
40
+ As this model is based on Llama 2, it is also subject to the Meta Llama 2 license terms.
41
+
42
+ ## Usage
43
+
44
+ - [Swift Transformers](https://github.com/huggingface/swift-transformers)
45
+
46
+ # Original Model Card: TinyLlama-1.1B
47
+
48
+ https://github.com/jzhang38/TinyLlama
49
+
50
+ The TinyLlama project aims to **pretrain** a **1.1B Llama model on 3 trillion tokens**. With some proper optimization, we can achieve this within a span of "just" 90 days using 16 A100-40G GPUs 🚀🚀. The training has started on 2023-09-01.
51
+
52
+
53
+ We adopted exactly the same architecture and tokenizer as Llama 2. This means TinyLlama can be plugged and played in many open-source projects built upon Llama. Besides, TinyLlama is compact with only 1.1B parameters. This compactness allows it to cater to a multitude of applications demanding a restricted computation and memory footprint.
54
+
55
+ #### This Model
56
+ This is the chat model finetuned on top of [PY007/TinyLlama-1.1B-intermediate-step-480k-1T](https://huggingface.co/PY007/TinyLlama-1.1B-intermediate-step-480k-1T).
57
+ The dataset used is [OpenAssistant/oasst_top1_2023-08-25](https://huggingface.co/datasets/OpenAssistant/oasst_top1_2023-08-25) following the [chatml](https://github.com/openai/openai-python/blob/main/chatml.md) format.
58
+ #### How to use
59
+ You will need the transformers>=4.31
60
+ Do check the [TinyLlama](https://github.com/jzhang38/TinyLlama) github page for more information.
61
+ ```
62
+ from transformers import AutoTokenizer
63
+ import transformers
64
+ import torch
65
+ model = "PY007/TinyLlama-1.1B-Chat-v0.3"
66
+ tokenizer = AutoTokenizer.from_pretrained(model)
67
+ pipeline = transformers.pipeline(
68
+ "text-generation",
69
+ model=model,
70
+ torch_dtype=torch.float16,
71
+ device_map="auto",
72
+ )
73
+
74
+ CHAT_EOS_TOKEN_ID = 32002
75
+
76
+ prompt = "How to get in a good university?"
77
+ formatted_prompt = (
78
+ f"<|im_start|>user\n{prompt}<|im_end|>\n<|im_start|>assistant\n"
79
+ )
80
+
81
+
82
+ sequences = pipeline(
83
+ formatted_prompt,
84
+ do_sample=True,
85
+ top_k=50,
86
+ top_p = 0.9,
87
+ num_return_sequences=1,
88
+ repetition_penalty=1.1,
89
+ max_new_tokens=1024,
90
+ eos_token_id=CHAT_EOS_TOKEN_ID,
91
+ )
92
+
93
+ for seq in sequences:
94
+ print(f"Result: {seq['generated_text']}")
95
+ ```