Downloads · 30 days
0
forcemultiplier/fastapply-xml-cot-3b-adapter
fastapply-xml-cot-3b-adapter is a machine learning model from forcemultiplier. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
TURBOPASTA is built upon the excellent work of Fast Apply by Kortix AI. Our model leverages their dataset and builds on their pioneering approach to code merging and transformation. Key inspirations include:
Downloads · 30 days
0
Access
Public
Updated Oct 25, 2024
Repo size
490 MB
Likes
1
Public
Click a slice to open those files.
.safetensors479 MB · 97%
From the Hugging Face model README
TURBOPASTA is built upon the excellent work of Fast Apply by Kortix AI. Our model leverages their dataset and builds on their pioneering approach to code merging and transformation. Key inspirations include:
Special thanks to:
While TURBOPASTA introduces its own innovations, the groundwork laid by Fast Apply was instrumental in making this project possible. We encourage users interested in code transformation models to also check out the original Fast Apply models:
This project is licensed under Apache-2.0, consistent with Fast Apply's open-source ethos.
Based on a dataset inspired by https://www.kortix.ai/
A LoRA adapter for unsloth/Qwen2.5-3B that merges code updates using chain-of-thought reasoning and maintains strict adherence to original code structure and formatting.
Input XML structure:
<instruction>You are a coding assistant that helps merge code updates, ensuring every modification is fully integrated. Merge all changes from the snippet into the code. Preserve the code's structure, order, comments, and indentation exactly.</instruction>
<fastapply>
<code>
{original_code}
</code>
<update>
{update_snippet}
</update>
<finalcode>
{merged_result}
</finalcode>
</fastapply>
The model supports multiple <fastapply> blocks for few-shot context learning. Use your stop token as </fastapply>.
export VLLM_ALLOW_RUNTIME_LORA_UPDATING=1
export VLLM_ALLOW_LONG_MAX_MODEL_LEN=1
vllm serve unsloth/qwen2.5-3b \
--gpu-memory-utilization=1 \
--port 6002 \
--served-model-name="turbopasta" \
--trust-remote-code \
--max-model-len 8192 \
--disable-log-requests \
--enable-lora \
--lora-modules lora=./dataset/output/turbopasta/lora_model \
--max-lora-rank 64
import requests
def merge_code(original_code: str, update_snippet: str, vllm_url: str = "http://localhost:6002/v1/completions") -> dict:
xml_content = (
'<instruction>You are a coding assistant that helps merge code updates, ensuring every modification is fully '
'integrated. Merge all changes from the snippet into the code. Preserve the code\'s structure, order, comments, '
'and indentation exactly.</instruction>\n'
'<fastapply>\n'
' <code>\n'
f'{original_code}\n'
' </code>\n'
' <update>\n'
f'{update_snippet}\n'
' </update>'
)
response = requests.post(
vllm_url,
json={
"prompt": xml_content,
"max_tokens": 6000,
"temperature": 0.1,
"model": "lora",
"stop": ["</fastapply>"]
},
timeout=30000
)
completion = response.json()["choices"][0]["text"]
# Parse XML tags
import re
def extract_tag(tag: str) -> str:
match = re.search(f'<{tag}>(.*?)</{tag}>', completion, re.DOTALL)
return match.group(1).strip() if match else ""
return {
"merged_code": extract_tag("finalcode")
}
The model works with the included data processor for parallel processing of code updates:
from request_processor import RequestProcessor
processor = RequestProcessor(
input_file="updates.jsonl",
output_file="merged.jsonl",
num_threads=24
)
processor.process_file()
Input JSONL format:
{
"id": "update_id",
"original_code": "...",
"update_snippet": "...",
"file_path": "path/to/file"
}
Output JSONL format:
{
"id": "update_id",
"original_code": "...",
"update_snippet": "...",
"merged_code": "...",
"file_path": "path/to/file",
"processed_at": "2024-10-24 02:52:33"
}
Errors are captured in the output JSONL:
{
"error": "error message",
"processed_at": "timestamp"
}
Monitor errors in real-time:
tail -f merged.jsonl | grep error
This model was trained using Force Multiplier's autotuning pipeline with the following key characteristics: