Tonic commited on
Commit
43f56f5
·
verified ·
1 Parent(s): afa3f20

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +162 -137
README.md CHANGED
@@ -1,199 +1,224 @@
1
  ---
 
2
  library_name: transformers
3
- tags: []
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  ---
5
 
6
- # Model Card for Model ID
7
 
8
- <!-- Provide a quick summary of what the model is/does. -->
9
 
 
10
 
 
11
 
12
- ## Model Details
13
-
14
- ### Model Description
15
-
16
- <!-- Provide a longer summary of what this model is. -->
17
-
18
- This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
19
-
20
- - **Developed by:** [More Information Needed]
21
- - **Funded by [optional]:** [More Information Needed]
22
- - **Shared by [optional]:** [More Information Needed]
23
- - **Model type:** [More Information Needed]
24
- - **Language(s) (NLP):** [More Information Needed]
25
- - **License:** [More Information Needed]
26
- - **Finetuned from model [optional]:** [More Information Needed]
27
-
28
- ### Model Sources [optional]
29
-
30
- <!-- Provide the basic links for the model. -->
31
-
32
- - **Repository:** [More Information Needed]
33
- - **Paper [optional]:** [More Information Needed]
34
- - **Demo [optional]:** [More Information Needed]
35
-
36
- ## Uses
37
-
38
- <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
39
-
40
- ### Direct Use
41
-
42
- <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
43
-
44
- [More Information Needed]
45
-
46
- ### Downstream Use [optional]
47
-
48
- <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
49
-
50
- [More Information Needed]
51
-
52
- ### Out-of-Scope Use
53
-
54
- <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
55
-
56
- [More Information Needed]
57
-
58
- ## Bias, Risks, and Limitations
59
-
60
- <!-- This section is meant to convey both technical and sociotechnical limitations. -->
61
-
62
- [More Information Needed]
63
-
64
- ### Recommendations
65
-
66
- <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
67
-
68
- Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
69
-
70
- ## How to Get Started with the Model
71
-
72
- Use the code below to get started with the model.
73
-
74
- [More Information Needed]
75
-
76
- ## Training Details
77
-
78
- ### Training Data
79
-
80
- <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
81
-
82
- [More Information Needed]
83
-
84
- ### Training Procedure
85
-
86
- <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
87
-
88
- #### Preprocessing [optional]
89
-
90
- [More Information Needed]
91
 
 
92
 
93
- #### Training Hyperparameters
 
 
 
 
 
 
94
 
95
- - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
96
 
97
- #### Speeds, Sizes, Times [optional]
 
 
 
 
98
 
99
- <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
100
 
101
- [More Information Needed]
102
 
103
- ## Evaluation
104
 
105
- <!-- This section describes the evaluation protocols and provides the results. -->
106
 
107
- ### Testing Data, Factors & Metrics
 
 
108
 
109
- #### Testing Data
110
 
111
- <!-- This should link to a Dataset Card if possible. -->
 
 
 
112
 
113
- [More Information Needed]
 
114
 
115
- #### Factors
 
 
 
116
 
117
- <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
 
118
 
119
- [More Information Needed]
 
 
120
 
121
- #### Metrics
 
 
 
 
 
 
 
 
 
122
 
123
- <!-- These are the evaluation metrics being used, ideally with a description of why. -->
 
 
 
124
 
125
- [More Information Needed]
126
 
127
- ### Results
128
 
129
- [More Information Needed]
 
 
 
130
 
131
- #### Summary
132
 
 
133
 
 
134
 
135
- ## Model Examination [optional]
136
 
137
- <!-- Relevant interpretability work for the model goes here -->
138
 
139
- [More Information Needed]
140
 
141
- ## Environmental Impact
142
 
143
- <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
 
 
 
 
 
144
 
145
- Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
146
 
147
- - **Hardware Type:** [More Information Needed]
148
- - **Hours used:** [More Information Needed]
149
- - **Cloud Provider:** [More Information Needed]
150
- - **Compute Region:** [More Information Needed]
151
- - **Carbon Emitted:** [More Information Needed]
152
 
153
- ## Technical Specifications [optional]
154
 
155
- ### Model Architecture and Objective
156
 
157
- [More Information Needed]
 
 
 
 
158
 
159
- ### Compute Infrastructure
160
 
161
- [More Information Needed]
162
 
163
- #### Hardware
164
 
165
- [More Information Needed]
166
 
167
- #### Software
168
 
169
- [More Information Needed]
170
 
171
- ## Citation [optional]
 
 
 
 
 
 
 
172
 
173
- <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
174
 
175
- **BibTeX:**
176
 
177
- [More Information Needed]
178
 
179
- **APA:**
180
 
181
- [More Information Needed]
182
 
183
- ## Glossary [optional]
184
 
185
- <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
186
 
187
- [More Information Needed]
188
 
189
- ## More Information [optional]
190
 
191
- [More Information Needed]
192
 
193
- ## Model Card Authors [optional]
194
 
195
- [More Information Needed]
196
 
197
- ## Model Card Contact
198
 
199
- [More Information Needed]
 
1
  ---
2
+ inference: false
3
  library_name: transformers
4
+ language:
5
+ - en
6
+ - fr
7
+ - de
8
+ - es
9
+ - it
10
+ - pt
11
+ - ja
12
+ - ko
13
+ - zh
14
+ - ar
15
+ - el
16
+ - fa
17
+ - pl
18
+ - id
19
+ - cs
20
+ - he
21
+ - hi
22
+ - nl
23
+ - ro
24
+ - ru
25
+ - tr
26
+ - uk
27
+ - vi
28
+ license: cc-by-nc-4.0
29
+ extra_gated_prompt: "By submitting this form, you agree to the [License Agreement](https://cohere.com/c4ai-cc-by-nc-license) and acknowledge that the information you provide will be collected, used, and shared in accordance with Cohere’s [Privacy Policy](https://cohere.com/privacy). You’ll receive email updates about C4AI and Cohere research, events, products and services. You can unsubscribe at any time."
30
+ extra_gated_fields:
31
+ Name: text
32
+ Affiliation: text
33
+ Country: country
34
+ I agree to use this model for non-commercial use ONLY: checkbox
35
+ tags:
36
+ - quantized
37
+ - 4bit
38
+ - 8bit
39
+ - multi-gpu
40
+ - nlp
41
+ - conversational-ai
42
+ - rag
43
+ - tool-use
44
+ - code-generation
45
+ - enterprise
46
+ model_name: C4AI Command A - Quantized
47
+ base_model: CohereForAI/c4ai-command-a-03-2025
48
+ model_size: 111B
49
+ context_length: 256K
50
+ developers:
51
+ - Cohere
52
+ - Cohere For AI
53
+ contact: [email protected]
54
  ---
55
 
56
+ # C4AI Command A - Quantized Models
57
 
58
+ This repository contains quantized versions of the **C4AI Command A** model, an open weights research release by [Cohere](https://cohere.com/) and [Cohere For AI](https://cohere.for.ai/). The original model is a 111 billion parameter language model optimized for enterprise use cases, excelling in agentic, multilingual, and retrieval-augmented generation (RAG) tasks while being deployable on minimal hardware (e.g., two GPUs). Here, we provide multiple quantized variants to further reduce memory footprint and enhance deployment flexibility across various hardware setups, including multi-GPU environments.
59
 
60
+ For details on the original model, refer to the [official model card](#model-card-for-c4ai-command-a) below.
61
 
62
+ ---
63
 
64
+ ## Quantized Models
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
 
66
+ We have quantized the original `CohereForAI/c4ai-command-a-03-2025` model using the `bitsandbytes` library with various configurations to balance performance, memory efficiency, and accuracy. Below are the available quantized versions:
67
 
68
+ | Quantization Type | Description | Compute Dtype | Double Quantization | Notes |
69
+ |---------------------------|-----------------------------------------------------------------------------|---------------|---------------------|--------------------------------------------|
70
+ | `4bit_nf4_double` | 4-bit quantization with `nf4` (Normal Float 4) | `bfloat16` | Yes | High precision with reduced memory usage |
71
+ | `4bit_fp4` | 4-bit quantization with `fp4` (Float Point 4) | `bfloat16` | No | Lightweight, slightly less precise |
72
+ | `8bit_standard` | Standard 8-bit quantization | `bfloat16` | N/A | Balanced memory and accuracy |
73
+ | `8bit_mixed` | 8-bit quantization with mixed precision and CPU offloading capability | `float16` | N/A | Flexible for constrained environments |
74
+ | `4bit_nf4_no_double` | 4-bit quantization with `nf4`, no double quantization | `bfloat16` | No | Minimal memory footprint |
75
 
76
+ These models are optimized for multi-GPU deployment using the `accelerate` library, ensuring efficient distribution across available GPUs. Each variant is hosted in its own sub-repository:
77
 
78
+ - `Tonic/c4ai-command-a-03-2025-4bit_nf4_double`
79
+ - `Tonic/c4ai-command-a-03-2025-4bit_fp4`
80
+ - `Tonic/c4ai-command-a-03-2025-8bit_standard`
81
+ - `Tonic/c4ai-command-a-03-2025-8bit_mixed`
82
+ - `Tonic/c4ai-command-a-03-2025-4bit_nf4_no_double`
83
 
84
+ ---
85
 
86
+ ## Usage
87
 
88
+ To use a quantized model, install the required dependencies and load the desired variant as shown below. Multi-GPU support is enabled via `accelerate`.
89
 
90
+ ### Installation
91
 
92
+ ```bash
93
+ pip install transformers bitsandbytes accelerate torch huggingface_hub
94
+ ```
95
 
96
+ ### Example: Loading and Generating Text
97
 
98
+ ```python
99
+ import torch
100
+ from transformers import AutoTokenizer, AutoModelForCausalLM
101
+ from accelerate import Accelerator
102
 
103
+ # Initialize Accelerator for multi-GPU support
104
+ accelerator = Accelerator()
105
 
106
+ # Specify the quantized model ID
107
+ model_id = "Tonic/c4ai-command-a-03-2025-4bit_nf4_double" # Replace with desired variant
108
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
109
+ model = AutoModelForCausalLM.from_pretrained(model_id, device_map="auto", torch_dtype=torch.bfloat16)
110
 
111
+ # Prepare model for multi-GPU
112
+ model = accelerator.prepare(model)
113
 
114
+ # Format message with chat template
115
+ messages = [{"role": "user", "content": "Hello, how are you?"}]
116
+ input_ids = tokenizer.apply_chat_template(messages, tokenize=True, add_generation_prompt=True, return_tensors="pt").to(accelerator.device)
117
 
118
+ # Generate text
119
+ gen_tokens = model.generate(
120
+ input_ids,
121
+ max_new_tokens=100,
122
+ do_sample=True,
123
+ temperature=0.3,
124
+ )
125
+ gen_text = tokenizer.decode(gen_tokens[0])
126
+ print(gen_text)
127
+ ```
128
 
129
+ ### Notes
130
+ - **Device Mapping**: `device_map="auto"` ensures the model is distributed across all available GPUs.
131
+ - **Compute Dtype**: Adjust `torch_dtype` (e.g., `torch.bfloat16` or `torch.float16`) based on your hardware and the quantization type.
132
+ - **Memory**: Quantized models significantly reduce VRAM requirements compared to the original 111B parameter model, making them suitable for deployment on consumer-grade GPUs.
133
 
134
+ ---
135
 
136
+ ## Quantization Details
137
 
138
+ The quantization process leverages `bitsandbytes` with the following configurations:
139
+ - **4-bit Variants**: Use `nf4` or `fp4` quantization types, with optional double quantization for improved precision.
140
+ - **8-bit Variants**: Offer standard or mixed precision options, with the latter supporting CPU offloading for additional flexibility.
141
+ - **Multi-GPU Optimization**: The `accelerate` library handles model sharding and distribution, allowing deployment on systems with multiple GPUs.
142
 
143
+ For the exact quantization script, see [this Gist](#) (replace with a link to your script if hosted).
144
 
145
+ ---
146
 
147
+ ## Model Card for C4AI Command A
148
 
149
+ Below is the original model card for `C4AI Command A`, adapted for this repository.
150
 
151
+ ---
152
 
153
+ ### Model Summary
154
 
155
+ C4AI Command A is an open weights research release of a 111 billion parameter model optimized for demanding enterprises that require fast, secure, and high-quality AI. Compared to other leading proprietary and open-weights models, Command A delivers maximum performance with minimum hardware costs, excelling on business-critical agentic and multilingual tasks while being deployable on just two GPUs.
156
 
157
+ - **Developed by**: [Cohere](https://cohere.com/) and [Cohere For AI](https://cohere.for.ai/)
158
+ - **Point of Contact**: Cohere For AI: [cohere.for.ai](https://cohere.for.ai/)
159
+ - **License**: [CC-BY-NC](https://cohere.com/c4ai-cc-by-nc-license), requires adhering to [C4AI's Acceptable Use Policy](https://docs.cohere.com/docs/c4ai-acceptable-use-policy)
160
+ - **Model**: `c4ai-command-a-03-2025`
161
+ - **Model Size**: 111 billion parameters
162
+ - **Context Length**: 256K
163
 
164
+ **Try C4AI Command A**
165
 
166
+ You can try the original model before downloading weights in the hosted [Hugging Face Space](https://cohereforai-c4ai-command.hf.space/models/command-a-03-2025).
 
 
 
 
167
 
168
+ ---
169
 
170
+ ### Model Details
171
 
172
+ - **Input**: Text only
173
+ - **Output**: Text only
174
+ - **Model Architecture**: Auto-regressive language model with an optimized transformer architecture, featuring sliding window attention (window size 4096) with RoPE, and a global attention layer without positional embeddings.
175
+ - **Languages**: Supports 23 languages including English, French, Spanish, German, Japanese, Chinese, Arabic, and more (see full list in the original model card).
176
+ - **Context Length**: 256K
177
 
178
+ ---
179
 
180
+ ### Chat Capabilities
181
 
182
+ Command A is configured as a conversational model by default with two safety modes: **contextual** (default, fewer constraints) and **strict** (avoids sensitive topics). See [Command A prompt format docs](https://docs.cohere.com/docs/command-a-hf) for details.
183
 
184
+ ---
185
 
186
+ ### RAG Capabilities
187
 
188
+ Command A excels in Retrieval Augmented Generation (RAG) tasks. Use the `apply_chat_template` method with document snippets for RAG functionality. Example:
189
 
190
+ ```python
191
+ conversation = [{"role": "user", "content": "What has Man always dreamed of?"}]
192
+ documents = [
193
+ {"heading": "The Moon", "body": "Man has always dreamed of destroying the moon..."},
194
+ {"heading": "Love", "body": "Man's dream has always been to find love..."}
195
+ ]
196
+ input_ids = tokenizer.apply_chat_template(conversation, documents=documents, tokenize=True, add_generation_prompt=True, return_tensors="pt")
197
+ ```
198
 
199
+ ---
200
 
201
+ ### Tool Use Capabilities
202
 
203
+ Command A supports conversational tool use with JSON schema-based tool descriptions. See the [tool use example](#tool-use-example-click-to-expand) in the original model card for implementation details.
204
 
205
+ ---
206
 
207
+ ### Code Capabilities
208
 
209
+ The model performs well on enterprise-relevant code tasks (e.g., SQL generation, code translation). Use low temperature or greedy decoding for optimal code generation.
210
 
211
+ ---
212
 
213
+ ## Terms of Use
214
 
215
+ This model is released under a [CC-BY-NC](https://cohere.com/c4ai-cc-by-nc-license) license for non-commercial use only, adhering to [C4AI's Acceptable Use Policy](https://docs.cohere.com/docs/c4ai-acceptable-use-policy). For commercial inquiries, contact [Cohere’s Sales team](https://cohere.com/contact-sales).
216
 
217
+ ---
218
 
219
+ ## Contact
220
 
221
+ For issues or questions, reach out to `[email protected]`.
222
 
223
+ ---
224