jeffra commited on
Commit
b268895
1 Parent(s): df1cc3b

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +22 -16
README.md CHANGED
@@ -39,33 +39,34 @@ Arctic combines a 10B dense transformer model with a residual 128x3.66B MoE MLP
39
  total and 17B active parameters chosen using a top-2 gating. For more details about Arctic's model
40
  Architecture, training process, data, etc. [see our series of cookbooks](https://www.snowflake.com/en/data-cloud/arctic/cookbook/).
41
 
42
-
43
  ## Usage
44
 
45
- As of 4/24/2024 we are actively working with the maintainers of `transformers` to include the Arctic
46
- model implementation. Until this support is released please follow these instructions to get the
47
- required dependencies for using Arctic:
 
48
 
49
  ```python
50
- pip install git+https://github.com/Snowflake-Labs/transformers.git@arctic
51
  ```
52
 
53
  Arctic leverages several features from [DeepSpeed](https://github.com/microsoft/DeepSpeed), you will need to
54
- install the latest version of DeepSpeed to get all of these required features:
55
 
56
  ```python
57
- pip install "deepspeed>=0.14.2"
58
  ```
59
 
60
- ### Inference
61
 
62
  Due to the model size we recommend using a single 8xH100 instance from your
63
  favorite cloud provider such as: AWS [p5.48xlarge](https://aws.amazon.com/ec2/instance-types/p5/),
64
  Azure [ND96isr_H100_v5](https://learn.microsoft.com/en-us/azure/virtual-machines/nd-h100-v5-series), etc.
65
 
66
  In this example we are using FP8 quantization provided by DeepSpeed in the backend, we can also use FP6
67
- quantization by specifying `q_bits=6` in the `ArcticQuantizationConfig` config. The `"150GiB"` setting
68
- for max_memory is required until we can get DeepSpeed's FP quantization supported natively as a [HFQuantizer](https://huggingface.co/docs/transformers/main/en/hf_quantizer#build-a-new-hfquantizer-class) which we
 
69
  are actively working on.
70
 
71
  ```python
@@ -75,24 +76,29 @@ os.environ["HF_HUB_ENABLE_HF_TRANSFER"] = "1"
75
 
76
  import torch
77
  from transformers import AutoModelForCausalLM, AutoTokenizer
78
- from transformers.models.arctic.configuration_arctic import ArcticQuantizationConfig
79
-
80
- tokenizer = AutoTokenizer.from_pretrained("Snowflake/snowflake-arctic-instruct")
81
 
82
- quant_config = ArcticQuantizationConfig(q_bits=8)
 
 
 
 
83
 
84
  model = AutoModelForCausalLM.from_pretrained(
85
  "Snowflake/snowflake-arctic-instruct",
 
86
  low_cpu_mem_usage=True,
87
  device_map="auto",
88
  ds_quantization_config=quant_config,
89
  max_memory={i: "150GiB" for i in range(8)},
90
  torch_dtype=torch.bfloat16)
91
 
92
- messages = [{"role": "user", "content": "What is 1 + 1 "}]
 
 
93
  input_ids = tokenizer.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt").to("cuda")
94
 
95
- outputs = model.generate(input_ids=input_ids, max_new_tokens=20)
96
  print(tokenizer.decode(outputs[0]))
97
  ```
98
 
 
39
  total and 17B active parameters chosen using a top-2 gating. For more details about Arctic's model
40
  Architecture, training process, data, etc. [see our series of cookbooks](https://www.snowflake.com/en/data-cloud/arctic/cookbook/).
41
 
 
42
  ## Usage
43
 
44
+ Arctic is currently supported with `transformers` by leveraging the
45
+ [custom code feature](https://huggingface.co/docs/transformers/en/custom_models#using-a-model-with-custom-code),
46
+ to use this you simply need to add `trust_remote_code=True` to your AutoTokenizer and AutoModelForCausalLM calls.
47
+ However, we recommend that you use a `transformers` version at or above 4.39:
48
 
49
  ```python
50
+ pip install transformers>=4.39.0
51
  ```
52
 
53
  Arctic leverages several features from [DeepSpeed](https://github.com/microsoft/DeepSpeed), you will need to
54
+ install the DeepSpeed 0.14.2 or higher to get all of these required features:
55
 
56
  ```python
57
+ pip install deepspeed>=0.14.2
58
  ```
59
 
60
+ ### Inference examples
61
 
62
  Due to the model size we recommend using a single 8xH100 instance from your
63
  favorite cloud provider such as: AWS [p5.48xlarge](https://aws.amazon.com/ec2/instance-types/p5/),
64
  Azure [ND96isr_H100_v5](https://learn.microsoft.com/en-us/azure/virtual-machines/nd-h100-v5-series), etc.
65
 
66
  In this example we are using FP8 quantization provided by DeepSpeed in the backend, we can also use FP6
67
+ quantization by specifying `q_bits=6` in the `QuantizationConfig` config. The `"150GiB"` setting
68
+ for max_memory is required until we can get DeepSpeed's FP quantization supported natively as a
69
+ [HFQuantizer](https://huggingface.co/docs/transformers/main/en/hf_quantizer#build-a-new-hfquantizer-class) which we
70
  are actively working on.
71
 
72
  ```python
 
76
 
77
  import torch
78
  from transformers import AutoModelForCausalLM, AutoTokenizer
79
+ from deepspeed.linear.config import QuantizationConfig
 
 
80
 
81
+ tokenizer = AutoTokenizer.from_pretrained(
82
+ "Snowflake/snowflake-arctic-instruct",
83
+ trust_remote_code=True
84
+ )
85
+ quant_config = QuantizationConfig(q_bits=8)
86
 
87
  model = AutoModelForCausalLM.from_pretrained(
88
  "Snowflake/snowflake-arctic-instruct",
89
+ trust_remote_code=True,
90
  low_cpu_mem_usage=True,
91
  device_map="auto",
92
  ds_quantization_config=quant_config,
93
  max_memory={i: "150GiB" for i in range(8)},
94
  torch_dtype=torch.bfloat16)
95
 
96
+
97
+ content = "5x + 35 = 7x - 60 + 10. Solve for x"
98
+ messages = [{"role": "user", "content": content}]
99
  input_ids = tokenizer.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt").to("cuda")
100
 
101
+ outputs = model.generate(input_ids=input_ids, max_new_tokens=256)
102
  print(tokenizer.decode(outputs[0]))
103
  ```
104