Text Generation
MLX
Safetensors
English
llama
climate
earth-science
geoscience
quantized
4-bit precision
conversational
Instructions to use xquantize/climategpt-7b-4bit-mlx with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use xquantize/climategpt-7b-4bit-mlx with MLX:
# Make sure mlx-lm is installed # pip install --upgrade mlx-lm # Generate text with mlx-lm from mlx_lm import load, generate model, tokenizer = load("xquantize/climategpt-7b-4bit-mlx") prompt = "Write a story about Einstein" messages = [{"role": "user", "content": prompt}] prompt = tokenizer.apply_chat_template( messages, add_generation_prompt=True ) text = generate(model, tokenizer, prompt=prompt, verbose=True) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- MLX LM
How to use xquantize/climategpt-7b-4bit-mlx with MLX LM:
Generate or start a chat session
# Install MLX LM uv tool install mlx-lm # Interactive chat REPL mlx_lm.chat --model "xquantize/climategpt-7b-4bit-mlx"
Run an OpenAI-compatible server
# Install MLX LM uv tool install mlx-lm # Start the server mlx_lm.server --model "xquantize/climategpt-7b-4bit-mlx" # Calling the OpenAI-compatible server with curl curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "xquantize/climategpt-7b-4bit-mlx", "messages": [ {"role": "user", "content": "Hello"} ] }' - Atomic Chat
Update README.md
Browse files
README.md
CHANGED
|
@@ -1,32 +1,41 @@
|
|
| 1 |
---
|
|
|
|
|
|
|
|
|
|
| 2 |
language:
|
| 3 |
- en
|
| 4 |
-
|
| 5 |
-
- OpenAssistant/oasst1
|
| 6 |
-
- databricks/databricks-dolly-15k
|
| 7 |
-
base_model: eci-io/climategpt-7b
|
| 8 |
tags:
|
| 9 |
-
- climate
|
| 10 |
- mlx
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
license_link: https://huggingface.co/eci-io/climategpt-7b/blob/main/LICENSE.txt
|
| 19 |
-
library_name: mlx
|
| 20 |
pipeline_tag: text-generation
|
| 21 |
---
|
| 22 |
|
| 23 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
-
##
|
| 30 |
|
| 31 |
```bash
|
| 32 |
pip install mlx-lm
|
|
@@ -37,13 +46,43 @@ from mlx_lm import load, generate
|
|
| 37 |
|
| 38 |
model, tokenizer = load("xquantize/climategpt-7b-4bit-mlx")
|
| 39 |
|
| 40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
|
| 42 |
-
|
| 43 |
-
messages = [{"role": "user", "content": prompt}]
|
| 44 |
-
prompt = tokenizer.apply_chat_template(
|
| 45 |
-
messages, add_generation_prompt=True, return_dict=False,
|
| 46 |
-
)
|
| 47 |
|
| 48 |
-
|
|
|
|
|
|
|
| 49 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
license: other
|
| 3 |
+
license_name: climategpt-community-license
|
| 4 |
+
license_link: https://huggingface.co/xquantize/climategpt-7b-4bit-mlx/blob/main/LICENSE.txt
|
| 5 |
language:
|
| 6 |
- en
|
| 7 |
+
library_name: mlx
|
|
|
|
|
|
|
|
|
|
| 8 |
tags:
|
|
|
|
| 9 |
- mlx
|
| 10 |
+
- climate
|
| 11 |
+
- earth-science
|
| 12 |
+
- geoscience
|
| 13 |
+
- quantized
|
| 14 |
+
- 4-bit
|
| 15 |
+
- llama
|
| 16 |
+
base_model: eci-io/climategpt-7b
|
|
|
|
|
|
|
| 17 |
pipeline_tag: text-generation
|
| 18 |
---
|
| 19 |
|
| 20 |
+
# ClimateGPT-7B-4bit-mlx
|
| 21 |
+
|
| 22 |
+
This is a 4-bit [MLX](https://github.com/ml-explore/mlx) quantization of [**ClimateGPT-7B**](https://huggingface.co/eci-io/climategpt-7b) (`eci-io/climategpt-7b`), a climate-domain chat model, converted for fast local inference on Apple Silicon.
|
| 23 |
+
|
| 24 |
+
ClimateGPT is a family of models designed to synthesize interdisciplinary research on climate change. The 7B model is continued-pretrained from Llama-2-7B on a curated collection of climate documents and then instruction fine-tuned on instruction–completion pairs collected in cooperation with climate scientists. The authors report it outperforms Llama-2-70B-Chat on their climate-specific benchmarks. See the original work for full detail:
|
| 25 |
+
|
| 26 |
+
> Thulke et al., *ClimateGPT: Towards AI Synthesizing Interdisciplinary Research on Climate Change*, 2024.
|
| 27 |
+
> Paper: <https://arxiv.org/abs/2401.09646> · Project: <https://eci.io>
|
| 28 |
+
|
| 29 |
+
## Conversion details
|
| 30 |
|
| 31 |
+
- **Method:** `mlx_lm.convert` with `-q --q-bits 4`
|
| 32 |
+
- **Result:** 4.500 bits per weight
|
| 33 |
+
- **Precision of base load:** bfloat16
|
| 34 |
+
- **Converted on:** Apple Silicon (MLX)
|
| 35 |
+
- **mlx-lm version:** 0.31.3
|
| 36 |
+
- **Base model:** `eci-io/climategpt-7b` (continued-pretrained from Llama-2-7B)
|
| 37 |
|
| 38 |
+
## Usage
|
| 39 |
|
| 40 |
```bash
|
| 41 |
pip install mlx-lm
|
|
|
|
| 46 |
|
| 47 |
model, tokenizer = load("xquantize/climategpt-7b-4bit-mlx")
|
| 48 |
|
| 49 |
+
# ClimateGPT is an instruction-tuned CHAT model — use the chat template.
|
| 50 |
+
messages = [
|
| 51 |
+
{"role": "user", "content": "What is the difference between weather and climate?"}
|
| 52 |
+
]
|
| 53 |
+
prompt = tokenizer.apply_chat_template(
|
| 54 |
+
messages, tokenize=False, add_generation_prompt=True
|
| 55 |
+
)
|
| 56 |
+
print(generate(model, tokenizer, prompt=prompt, max_tokens=256, verbose=True))
|
| 57 |
+
```
|
| 58 |
|
| 59 |
+
Or from the command line:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
|
| 61 |
+
```bash
|
| 62 |
+
mlx_lm.generate --model xquantize/climategpt-7b-4bit-mlx \
|
| 63 |
+
--prompt "What is the difference between weather and climate?" --max-tokens 128
|
| 64 |
```
|
| 65 |
+
|
| 66 |
+
### Note on usage style
|
| 67 |
+
|
| 68 |
+
This is an **instruction-tuned chat model**, so prompt it with chat turns via the tokenizer's chat template (shown above) rather than raw text completion. It uses a ChatML-style format (`<|im_start|>` / `<|im_end|>`). The authors note the model is designed to be used with retrieval augmentation (RAG) to extend its knowledge and improve factuality and is **not** intended as a general-purpose chatbot, it is specialized for the climate domain. Context length is 4K tokens.
|
| 69 |
+
|
| 70 |
+
### Stop-token fix
|
| 71 |
+
|
| 72 |
+
The upstream `generation_config.json` sets `eos_token_id` to `2` (Llama-2's `</s>`), but this model actually ends turns with the ChatML token `<|im_end|>` (id `32006`). As shipped upstream that mismatch causes generation to run past the end of a turn and repeat. This repository sets `eos_token_id` to `[2, 32006]`, so generation stops cleanly at the end of a turn with no extra flags required.
|
| 73 |
+
|
| 74 |
+
## Performance
|
| 75 |
+
|
| 76 |
+
On an Apple Silicon Mac, this 4-bit build runs at ~34 tokens/sec with a peak memory footprint of ~4.0 GB, making a climate-specialized 7B usable on consumer hardware.
|
| 77 |
+
|
| 78 |
+
## Limitations
|
| 79 |
+
|
| 80 |
+
ClimateGPT-7B is a 2024-era Llama-2-7B derivative; its general fluency and knowledge reflect that generation, not current frontier models. As with any chat-capable LLM, it may produce biased, offensive or inaccurate responses and should not be relied on for authoritative scientific or safety-critical decisions. It is intended to be paired with retrieval augmentation. Quantization to 4 bits may introduce additional minor quality degradation relative to the full-precision model.
|
| 81 |
+
|
| 82 |
+
## License & attribution
|
| 83 |
+
|
| 84 |
+
This model is a 4-bit MLX quantization of ClimateGPT-7B and is distributed under the **ClimateGPT Non-Commercial Community License** (© EQTY R&D, Inc.; Erasmus.AI as third-party beneficiary). **Non-commercial use only.**
|
| 85 |
+
|
| 86 |
+
Per the license, this repository includes a copy of the license (`LICENSE.txt`) and the required attribution (`Notice`). By using these weights you agree to the ClimateGPT Terms of Service and Acceptable Use Policy contained in `LICENSE.txt`.
|
| 87 |
+
|
| 88 |
+
All credit for the underlying model belongs to the ClimateGPT authors (Thulke et al.; Erasmus AI, AppTek, EQTY R&D). This repository provides only an MLX-format 4-bit quantization for local inference on Apple Silicon and claims no ownership of the underlying model. The "ClimateGPT" name is used solely to describe the origin of these weights.
|