Instructions to use QuantFactory/Refact-1_6-base-GGUF with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use QuantFactory/Refact-1_6-base-GGUF with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="QuantFactory/Refact-1_6-base-GGUF")# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("QuantFactory/Refact-1_6-base-GGUF", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use QuantFactory/Refact-1_6-base-GGUF with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf QuantFactory/Refact-1_6-base-GGUF:Q4_K_M # Run inference directly in the terminal: llama cli -hf QuantFactory/Refact-1_6-base-GGUF:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf QuantFactory/Refact-1_6-base-GGUF:Q4_K_M # Run inference directly in the terminal: llama cli -hf QuantFactory/Refact-1_6-base-GGUF:Q4_K_M
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf QuantFactory/Refact-1_6-base-GGUF:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf QuantFactory/Refact-1_6-base-GGUF:Q4_K_M
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf QuantFactory/Refact-1_6-base-GGUF:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf QuantFactory/Refact-1_6-base-GGUF:Q4_K_M
Use Docker
docker model run hf.co/QuantFactory/Refact-1_6-base-GGUF:Q4_K_M
- LM Studio
- Jan
- vLLM
How to use QuantFactory/Refact-1_6-base-GGUF with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "QuantFactory/Refact-1_6-base-GGUF" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "QuantFactory/Refact-1_6-base-GGUF", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/QuantFactory/Refact-1_6-base-GGUF:Q4_K_M
- SGLang
How to use QuantFactory/Refact-1_6-base-GGUF with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "QuantFactory/Refact-1_6-base-GGUF" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "QuantFactory/Refact-1_6-base-GGUF", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "QuantFactory/Refact-1_6-base-GGUF" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "QuantFactory/Refact-1_6-base-GGUF", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Ollama
How to use QuantFactory/Refact-1_6-base-GGUF with Ollama:
ollama run hf.co/QuantFactory/Refact-1_6-base-GGUF:Q4_K_M
- Unsloth Studio
How to use QuantFactory/Refact-1_6-base-GGUF with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for QuantFactory/Refact-1_6-base-GGUF to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for QuantFactory/Refact-1_6-base-GGUF to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for QuantFactory/Refact-1_6-base-GGUF to start chatting
- Docker Model Runner
How to use QuantFactory/Refact-1_6-base-GGUF with Docker Model Runner:
docker model run hf.co/QuantFactory/Refact-1_6-base-GGUF:Q4_K_M
- Lemonade
How to use QuantFactory/Refact-1_6-base-GGUF with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull QuantFactory/Refact-1_6-base-GGUF:Q4_K_M
Run and chat with the model
lemonade run user.Refact-1_6-base-GGUF-Q4_K_M
List all available models
lemonade list
- Atomic Chat
Upload README.md with huggingface_hub
Browse files
README.md
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
---
|
| 3 |
+
|
| 4 |
+
pipeline_tag: text-generation
|
| 5 |
+
inference: true
|
| 6 |
+
widget:
|
| 7 |
+
- text: 'def print_hello_world():'
|
| 8 |
+
example_title: Hello world
|
| 9 |
+
group: Python
|
| 10 |
+
license: bigscience-openrail-m
|
| 11 |
+
datasets:
|
| 12 |
+
- books
|
| 13 |
+
- arxiv
|
| 14 |
+
- c4
|
| 15 |
+
- falcon-refinedweb
|
| 16 |
+
- wiki
|
| 17 |
+
- github-issues
|
| 18 |
+
- stack_markdown
|
| 19 |
+
library_name: transformers
|
| 20 |
+
tags:
|
| 21 |
+
- code
|
| 22 |
+
language:
|
| 23 |
+
- en
|
| 24 |
+
|
| 25 |
+
---
|
| 26 |
+
|
| 27 |
+
[](https://hf.co/QuantFactory)
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
# QuantFactory/Refact-1_6-base-GGUF
|
| 31 |
+
This is quantized version of [smallcloudai/Refact-1_6-base](https://huggingface.co/smallcloudai/Refact-1_6-base) created using llama.cpp
|
| 32 |
+
|
| 33 |
+
# Original Model Card
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+

|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
# Refact-1.6B-base
|
| 40 |
+
|
| 41 |
+
Finally, the model we started training with our [blog post](https://refact.ai/blog/2023/applying-recent-innovations-to-train-model/) is ready 🎉
|
| 42 |
+
The model might contain some problems, especially with the FIM format
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
# It Works As a Chat
|
| 46 |
+
|
| 47 |
+
The primary application of this model is code completion (infill) in multiple programming languages.
|
| 48 |
+
But it works as a chat quite well.
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
# Example
|
| 52 |
+
|
| 53 |
+
Fill-in-the-middle uses special tokens to identify the prefix/middle/suffix part of the input and output:
|
| 54 |
+
|
| 55 |
+
```python
|
| 56 |
+
# pip install -q transformers
|
| 57 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 58 |
+
|
| 59 |
+
checkpoint = "smallcloudai/Refact-1_6B-fim"
|
| 60 |
+
device = "cuda" # for GPU usage or "cpu" for CPU usage
|
| 61 |
+
|
| 62 |
+
tokenizer = AutoTokenizer.from_pretrained(checkpoint)
|
| 63 |
+
model = AutoModelForCausalLM.from_pretrained(checkpoint, trust_remote_code=True).to(device)
|
| 64 |
+
|
| 65 |
+
prompt = '<fim_prefix>def print_hello_world():\n """<fim_suffix>\n print("Hello world!")<fim_middle>'
|
| 66 |
+
|
| 67 |
+
inputs = tokenizer.encode(prompt, return_tensors="pt").to(device)
|
| 68 |
+
outputs = model.generate(inputs, max_length=100, temperature=0.2)
|
| 69 |
+
print("-"*80)
|
| 70 |
+
print(tokenizer.decode(outputs[0]))
|
| 71 |
+
```
|
| 72 |
+
|
| 73 |
+
# Chat Format
|
| 74 |
+
|
| 75 |
+
The same model works as chat (experimental).
|
| 76 |
+
|
| 77 |
+
```python
|
| 78 |
+
prompt_template = "<empty_output>SYSTEM {system}\n" \
|
| 79 |
+
"<empty_output>USER {query}\n" \
|
| 80 |
+
"<empty_output>ASSISTANT"
|
| 81 |
+
prompt = prompt_template.format(system="You are a programming assistant",
|
| 82 |
+
query="How do I sort a list in Python?")
|
| 83 |
+
```
|
| 84 |
+
|
| 85 |
+
# Architecture
|
| 86 |
+
|
| 87 |
+
As described in more detail in the blog post, we used:
|
| 88 |
+
|
| 89 |
+
- [ALiBi](https://arxiv.org/abs/2108.12409) based attention
|
| 90 |
+
- [LayerNorm](https://arxiv.org/abs/1607.06450v1) instead of [RMSNorm](https://arxiv.org/pdf/1910.07467.pdf)
|
| 91 |
+
- [Multi Query Attention](https://arxiv.org/abs/1911.02150)
|
| 92 |
+
|
| 93 |
+
We also used LiON, flash attention, early dropout. It's not that innovative that you can't run it, in fact you can -- see an example below.
|
| 94 |
+
|
| 95 |
+
|
| 96 |
+
# Training
|
| 97 |
+
|
| 98 |
+
For the base model, we used our own dataset that contains code with permissive licenses only, and open text datasets.
|
| 99 |
+
Filtering is the key to success of this model:
|
| 100 |
+
|
| 101 |
+
- We only used text in English
|
| 102 |
+
- Only topics related to computer science
|
| 103 |
+
- Applied heavy deduplication
|
| 104 |
+
|
| 105 |
+
The text to code proportion was 50:50, model trained for 1.2T tokens.
|
| 106 |
+
|
| 107 |
+
We don't release the base model, because its Fill-in-the-Middle (FIM) capability likes to repeat itself too much, so
|
| 108 |
+
its practical use is limited. But if you still want it, write us a message on Discord.
|
| 109 |
+
|
| 110 |
+
|
| 111 |
+
# Limitations and Bias
|
| 112 |
+
|
| 113 |
+
The Refact-1.6B model was trained on text in English. But it has seen a lot more languages in
|
| 114 |
+
code comments. Its performance on non-English languages is lower, for sure.
|
| 115 |
+
|
| 116 |
+
|
| 117 |
+
# Model Stats
|
| 118 |
+
|
| 119 |
+
- **Architecture:** LLAMA-like model with multi-query attention
|
| 120 |
+
- **Objectives** Fill-in-the-Middle, Chat
|
| 121 |
+
- **Tokens context:** 4096
|
| 122 |
+
- **Pretraining tokens:** 1.2T
|
| 123 |
+
- **Finetuning tokens:** 40B
|
| 124 |
+
- **Precision:** bfloat16
|
| 125 |
+
- **GPUs** 64 NVidia A5000
|
| 126 |
+
- **Training time** 28 days
|
| 127 |
+
|
| 128 |
+
|
| 129 |
+
# License
|
| 130 |
+
|
| 131 |
+
The model is licensed under the BigScience OpenRAIL-M v1 license agreement
|
| 132 |
+
|
| 133 |
+
|
| 134 |
+
# Citation
|
| 135 |
+
|
| 136 |
+
If you are using this model, please give a link to this page.
|