As of October 2023, there are several local Large Language Models (LLMs) that excel at fill-in-the-middle (FIM) or autocomplete tasks, which are particularly useful for code generation, text editing, and creative writing. These models have been optimized to predict missing sections of text, making them ideal for tasks where you need to generate content in the middle of a sentence or paragraph.
Here’s a breakdown of some of the best local LLMs for FIM/autocomplete tasks:
1. StarCoder & StarCoderBase
- Developed by: BigCode Project (led by Hugging Face and ServiceNow)
- Key Features:
- Fill-in-the-Middle (FIM): StarCoder was specifically designed with FIM capabilities in mind, making it highly effective for autocomplete tasks.
- Code-Centric: While primarily trained on code, it can also handle natural language tasks effectively.
- Multilingual Support: Supports over 80 programming languages.
- Size Options: Available in 15B parameters (StarCoderBase) and fine-tuned versions like StarCoder.
- Performance:
- Outperforms many other models in code-related autocomplete tasks.
- Handles both short and long-range dependencies well.
- Local Usage: Can be run locally using tools like Ollama or Hugging Face Transformers.
- Resources:
2. CodeLlama
- Developed by: Meta
- Key Features:
- Specialized for Code Completion: CodeLlama is an extension of Llama 2, fine-tuned specifically for code generation and autocomplete.
- FIM Capabilities: Supports fill-in-the-middle tasks, making it suitable for code editing and completion.
- Variants: Comes in different sizes (7B, 13B, 34B parameters), with specialized versions like CodeLlama-Python and CodeLlama-Instruct.
- Natural Language Support: While focused on code, it retains strong natural language understanding.
- Performance:
- Excellent for developers looking for a powerful local model for coding tasks.
- Comparable to or better than StarCoder in certain benchmarks.
- Local Usage: Can be run locally using Hugging Face Transformers or Ollama.
- Resources:
3. WizardCoder
- Developed by: Microsoft
- Key Features:
- Fine-Tuned for Code Completion: WizardCoder is a fine-tuned version of Code LLMs, optimized for advanced code generation and autocomplete.
- State-of-the-Art Performance: Performs exceptionally well in coding benchmarks like HumanEval.
- FIM Support: While not explicitly marketed as a FIM model, its advanced reasoning capabilities make it excellent for autocomplete tasks.
- Performance:
- One of the best models for code-related autocomplete, especially for complex programming tasks.
- Local Usage: Can be run locally using Hugging Face Transformers or GGUF formats via llama.cpp.
- Resources:
4. Llama 2
- Developed by: Meta
- Key Features:
- General-Purpose Model: While not specifically designed for FIM, Llama 2 has been fine-tuned for various tasks, including text completion and code generation.
- Variants: Available in 7B, 13B, and 70B parameter versions.
- Instruction-Tuned Versions: Llama 2-Chat and Llama 2-Instruct are optimized for conversational and task-specific use cases.
- Performance:
- Strong performance across a wide range of tasks, including autocomplete.
- Not as specialized as StarCoder or CodeLlama for FIM but still highly capable.
- Local Usage: Can be run locally using Ollama, Hugging Face Transformers, or llama.cpp.
- Resources:
5. Falcon Instruct
- Developed by: TII (Technology Innovation Institute)
- Key Features:
- High-Quality Text Generation: Falcon Instruct is fine-tuned for instruction-following and text completion tasks.
- FIM Capabilities: While not explicitly designed for FIM, it performs well in text-based autocomplete scenarios.
- Variants: Available in 7B and 40B parameter versions.
- Performance:
- Strong performance in natural language autocomplete tasks.
- Competes with Llama 2 and other general-purpose models.
- Local Usage: Can be run locally using Hugging Face Transformers or GGUF formats via llama.cpp.
- Resources:
6. Mistral 7B
- Developed by: Mistral AI
- Key Features:
- State-of-the-Art Small Model: Mistral 7B is one of the best-performing models in its size category.
- Advanced Reasoning: Capable of handling complex autocomplete tasks, both for code and natural language.
- Efficient: Despite being smaller (7B parameters), it outperforms many larger models.
- Performance:
- Excellent for local deployment due to its efficiency and strong performance.
- Suitable for both code and text autocomplete.
- Local Usage: Can be run locally using Hugging Face Transformers or GGUF formats via llama.cpp.
- Resources:
7. GPT-J / GPT-NeoX
- Developed by: EleutherAI
- Key Features:
- Legacy Models: GPT-J (6B parameters) and GPT-NeoX (20B parameters) are older but still powerful open-source models.
- FIM Support: While not explicitly designed for FIM, they can handle autocomplete tasks reasonably well.
- Performance:
- Good for lightweight local deployments.
- Outperformed by newer models like StarCoder and CodeLlama but still viable for basic tasks.
- Local Usage: Can be run locally using Hugging Face Transformers or GGUF formats via llama.cpp.
- Resources:
Which Model Should You Choose?
-
For Code Autocomplete/FIM:
- Best Choice: StarCoder or CodeLlama
- Both are specifically optimized for code-related tasks and FIM capabilities.
-
For General Text Autocomplete:
- Best Choice: Llama 2, Mistral 7B, or Falcon Instruct
- These models perform well across a variety of natural language tasks, including autocomplete.
-
For Lightweight Local Deployment:
- Best Choice: Mistral 7B or GPT-J
- These models are smaller and more efficient, making them suitable for systems with limited resources.
Tools for Running Local LLMs
If you’re planning to run these models locally, here are some popular tools:
- Ollama: Simplifies running models like Llama 2, CodeLlama, and Mistral locally. Website
- Hugging Face Transformers: A comprehensive library for running models. Website
- llama.cpp: Optimized for running quantized models efficiently. GitHub
- Text Generation Web UI: A user-friendly interface for running models locally. GitHub
Conclusion
For fill-in-the-middle (FIM) or autocomplete tasks, StarCoder and CodeLlama are currently the top choices due to their specialized training and capabilities. If you're looking for a more general-purpose model, Llama 2, Mistral 7B, or Falcon Instruct are excellent alternatives. All of these models can be run locally with the right tools, allowing you to harness their power without relying on cloud services.
Final Recommendation:
- For Code Autocomplete: StarCoder or CodeLlama
- For General Text Autocomplete: Mistral 7B or Llama 2
Let me know if you need further guidance on setting up any of these models locally!