Instructions to use modularai/replit-code-1.5 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use modularai/replit-code-1.5 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 modularai/replit-code-1.5:BF16 # Run inference directly in the terminal: llama cli -hf modularai/replit-code-1.5:BF16
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf modularai/replit-code-1.5:BF16 # Run inference directly in the terminal: llama cli -hf modularai/replit-code-1.5:BF16
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 modularai/replit-code-1.5:BF16 # Run inference directly in the terminal: ./llama-cli -hf modularai/replit-code-1.5:BF16
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 modularai/replit-code-1.5:BF16 # Run inference directly in the terminal: ./build/bin/llama-cli -hf modularai/replit-code-1.5:BF16
Use Docker
docker model run hf.co/modularai/replit-code-1.5:BF16
- LM Studio
- Jan
- Ollama
How to use modularai/replit-code-1.5 with Ollama:
ollama run hf.co/modularai/replit-code-1.5:BF16
- Unsloth Studio
How to use modularai/replit-code-1.5 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 modularai/replit-code-1.5 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 modularai/replit-code-1.5 to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for modularai/replit-code-1.5 to start chatting
- Atomic Chat new
- Docker Model Runner
How to use modularai/replit-code-1.5 with Docker Model Runner:
docker model run hf.co/modularai/replit-code-1.5:BF16
- Lemonade
How to use modularai/replit-code-1.5 with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull modularai/replit-code-1.5:BF16
Run and chat with the model
lemonade run user.replit-code-1.5-BF16
List all available models
lemonade list
| language: | |
| - en | |
| license: apache-2.0 | |
| model_name: Replit Code V-1.5 3B | |
| base_model: replit/replit-code-v1_5-3b | |
| inference: false | |
| model_creator: Replit | |
| quantized_by: tzhenghao | |
| datasets: | |
| - bigcode/the-stack-dedup | |
| - togethercomputer/RedPajama-Data-1T | |
| tags: | |
| - code | |
| - Composer | |
| - MosaicML | |
| - llm-foundry | |
| - StreamingDatasets | |
| # Replit Code V-1.5 3B - GGUF | |
| - Model creator: [Replit](https://huggingface.co/replit) | |
| - Original model: [Replit Code V-1.5 3B](https://huggingface.co/replit/replit-code-v1_5-3b) | |
| - GGUF models quantized by: [tzhenghao](https://huggingface.co/tzhenghao) | |
| <!-- description start --> | |
| ## Description | |
| This repo contains GGUF format model files for [Replit Code V-1.5 3B](https://huggingface.co/replit/replit-code-v1_5-3b). | |
| <!-- description end --> | |
| <!-- original-model-card start --> | |
| ## Model Description | |
| Replit Code v1.5 is a 3.3B parameter Causal Language Model focused on **Code Completion**. | |
| The model is trained in `bfloat16` on 1T tokens of code (~200B tokens over 5 epochs, including linear cooldown) for 30 programming languages from a subset of permissively licensed code from Bigcode's [Stack Dedup dataset](https://huggingface.co/datasets/bigcode/the-stack-dedup), a filtered natural language sample from Markdown and reStructuredText subsets from the same Stack Dedup dataset, and a dev-oriented sample from [RedPajama's StackExchange dataset](https://github.com/togethercomputer/RedPajama-Data) sourced from the [Stack Exchange Data Dump by Stack Exchange Inc](https://archive.org/details/stackexchange). | |
| The 30 programming languages are: | |
| ``` | |
| Java, JavaScript, C, PHP, Python, C++, C#, TypeScript, Go, CSS, HTML, Rust, Ruby, Swift, Scala, Shell, Lua, Perl, Haskell, JSX, Julia, Common Lisp, OCaml, Solidity, Scheme, R, Zig, SQL, Racket, D | |
| ``` | |
| The context size of the model is 4096 tokens. We use the GPTNeoX tokenizer with a custom trained and optimized vocabulary of 32768 tokens. This custom vocabulary led to single-digit % points on compression while maintaining or improving coverage on our training corpus. | |
| The model has been trained on the [MosaicML](https://www.mosaicml.com/) platform on 128 H100-80GB GPUs using their [LLM Foundry](https://github.com/mosaicml/llm-foundry) and [Composer](https://github.com/mosaicml/composer) training library built on top of PyTorch. | |
| ## Dependencies | |
| You will need to install the latest versions of the following dependencies: | |
| ``` | |
| einops | |
| torch | |
| transformers | |
| ``` | |
| ## How to Use | |
| ### Generation | |
| You can generate code using the `transformers` library as follows: | |
| ```python | |
| from transformers import AutoModelForCausalLM, AutoTokenizer | |
| tokenizer = AutoTokenizer.from_pretrained('replit/replit-code-v1_5-3b', trust_remote_code=True) | |
| model = AutoModelForCausalLM.from_pretrained('replit/replit-code-v1_5-3b', trust_remote_code=True) | |
| x = tokenizer.encode('def fibonacci(n): ', return_tensors='pt') | |
| y = model.generate(x, max_length=100, do_sample=True, top_p=0.95, top_k=4, temperature=0.2, num_return_sequences=1, eos_token_id=tokenizer.eos_token_id) | |
| # decoding | |
| generated_code = tokenizer.decode(y[0], skip_special_tokens=True, clean_up_tokenization_spaces=False) | |
| print(generated_code) | |
| ``` | |
| Experiment with different decoding methods and parameters to get the best results for your use case. | |
| ### Using Triton Implementation of Flash Attention | |
| ```python | |
| import torch | |
| from transformers import AutoTokenizer, AutoModelForCausalLM, AutoConfig | |
| config = AutoConfig.from_pretrained( | |
| "replit/replit-code-v1_5-3b", | |
| trust_remote_code=True | |
| ) | |
| config.attn_config['attn_impl'] = 'triton' | |
| # load model | |
| tokenizer = AutoTokenizer.from_pretrained('replit/replit-code-v1_5-3b', trust_remote_code=True) | |
| model = AutoModelForCausalLM.from_pretrained('replit/replit-code-v1_5-3b', config=config, trust_remote_code=True) | |
| model.to(device='cuda:0', dtype=torch.bfloat16) | |
| # forward pass | |
| x = tokenizer.encode('def fibonacci(n): ', return_tensors='pt').to(device='cuda:0') | |
| x = x.to(device='cuda:0') | |
| y = model.generate(x, max_length=100, do_sample=True, top_p=0.95, top_k=4, temperature=0.2, num_return_sequences=1, eos_token_id=tokenizer.eos_token_id) | |
| # decoding | |
| generated_code = tokenizer.decode(y[0], skip_special_tokens=True, clean_up_tokenization_spaces=False) | |
| print(generated_code) | |
| ``` | |
| Experiment with different decoding methods and parameters to get the best results for your use case. We recommend experimenting with `temperature` and `reptition_penalty`for optimal performance on your use case! | |
| ## Intended Use | |
| Replit intends this model be used by anyone as a foundational model for application-specific fine-tuning without strict limitations on commercial use. | |
| The model is trained specifically for code completion tasks. | |
| ## Limitations | |
| The pre-training dataset may have contained offensive or inappropriate content even after applying data cleansing and toxicity and profanity filters, and such content may be reflected in model generated text. We recommend that users exercise reasonable caution when using in production systems. Do not use for any applications that may cause harm or distress to individuals or groups. | |
| <!-- original-model-card end --> | |