n a m e n o t f o u n d . a i
T H E
F U T U R E
O F
A I
I S
O N - D E V I C E
ImpproveLLMStructure — An intelligent correct system for LLM's
Identifies the incoming prompt and the LLM response than aligns and converts, improves system stability and allows for working with less capable models. For instance if you send a prompt request in python or json or plaintext it will try to reason the expected format and convert the LLM responses to whatever you want to recieve back.
A powerful open-source framework for building agentic AI systems that enables seamless communication between specialized language models through format transformation.
Improved LLM Structure is a crucial component in building agentic AI systems, particularly when working with multiple specialized language models. It solves a fundamental challenge in AI infrastructure: enabling different models to communicate effectively by transforming their outputs into various formats.
Overview:
https://www.loom.com/share/f19ac59a21ad4fd4b422552e958b3385?sid=1e26e48d-2643-4003-9288-1e65eb02de0f
- Format Transformation: Convert between different data formats (JSON, Markdown, Python, plain text)
- Local Model Integration: Works with quantized 8-bit models for efficient local processing
- Error Correction: Built-in validation and error correction system
- Learning System: Improves over time through interaction data
- Flexible API: RESTful interface for easy integration
- Multi-Format Support: Handle various input and output formats seamlessly
When building agentic AI systems with multiple specialized models, each model might excel at different tasks and output formats. This tool acts as a "universal translator" between these models, allowing them to communicate effectively without:
- Consuming large context windows with format-specific tokens
- Compromising model performance by forcing specific output formats
- Requiring larger, more resource-intensive models for format transformation
- Python 3.10 or newer
- Conda environment (recommended)
- Hugging Face model (8-bit quantized model recommended)
- Basic understanding of API communication
https://www.loom.com/share/51b53e0a7200458a97923b21a0cc2d69?sid=df63c202-f36f-4db4-a800-635027cf25a2
- Clone the repository:
git clone https://github.com/yourusername/improved-llm-structure.git
cd improved-llm-structure- Set up the Conda environment (recommended to use the same environment as the A-agent project):
git clone https://github.com/namenotfound-ai/a_agentFollow the setup requirements here:
https://www.loom.com/share/f19ac59a21ad4fd4b422552e958b3385?sid=1e26e48d-2643-4003-9288-1e65eb02de0f
- Install git-lfs (required for downloading the model):
# For macOS using Homebrew
brew install git-lfs
# Initialize git-lfs
git lfs install- Download the phi-4-8bit model:
# Create a local_models directory
mkdir local_models
cd local_models
# Clone the model repository
# Note: This will download approximately 15GB of model files and may take several minutes
git clone https://huggingface.co/mlx-community/phi-4-8bit --progress
# If you want to clone without large files - just their pointers
# GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/mlx-community/phi-4-8bit- Install the required Python packages:
pip install mlx-lm- Copy the local_model.py file to the model directory:
# From the project root directory
cp local_model.py local_models/phi-4-8bit/- Download a Hugging Face model (8-bit quantized model recommended) and place it in the project directory.
- Start the local model server:
# Navigate to the model directory
cd local_models/phi-4-8bit
# Start the server
python local_model.pyThis will start the server on port 5015 by default.
- Start the main application:
python app.pyThis will start the server on port 5025 by default.
- Make requests to the API using curl or any HTTP client:
curl -X POST http://localhost:5015/ask \
-H "Content-Type: application/json" \
-d '{
"question": "Your input text here",
"requested_format": "json"
}'Example:
curl -X POST \
http://localhost:5015/ask \
-H "Content-Type: application/json" \
-d '{
"question": "Convert this text to json: Name: John Smith, Age: 35, Occupation: Software Engineer, Skills: Python, JavaScript, SQL",
"output_format": "json"
}'You can modify the following settings in config.py:
- Local model endpoint
- Port numbers
- Default output format
- Other configuration parameters
The system consists of several key components:
app.py: Main application serverlocal_model.py: Local MLX model interfaceprompt_handler.py: Request and prompt processingllm_manager.py: LLM communicationoutput_parser.py: Output processingformat_transformer.py: Format transformationvalidator.py: Output validationerror_corrector.py: Error handlinglearner.py: Learning system
We welcome contributions! Please feel free to submit pull requests, open issues, or suggest improvements.
This project is open source and available under the MIT License.
- Download and set up the project
- Configure your environment
- Start the required servers
- Begin making API requests
- Reach out with any questions or feedback
For questions, feedback, or collaboration opportunities, please reach out to us through GitHub issues or our contact channels.
Remember: The future of AI isn't about making one model do everything. It's about making specialized models work together seamlessly.