Leanstral-1.5-119B-A6B震撼发布:重新定义Lean 4代码助手的终极AI模型
【免费下载链接】Leanstral-1.5-119B-A6B项目地址: https://ai.gitcode.com/hf_mirrors/mistralai/Leanstral-1.5-119B-A6B
Leanstral-1.5-119B-A6B是一款专为Lean 4设计的开源代码助手AI模型,它重新定义了证明助手的能力边界,能够处理复杂的数学对象和软件规范。作为Mistral Small 4家族的重要成员,该模型融合了多模态能力和高效架构,在性能和成本效益上超越了许多闭源替代方案。
核心特性:重新定义Lean 4代码助手的终极体验 🚀
Leanstral-1.5-119B-A6B带来了多项突破性的架构选择,使其成为目前最强大的Lean 4代码助手之一:
- MoE架构:128个专家,每个token激活4个专家,实现高效计算
- 模型规模:119B参数,每个token激活6.5B参数,平衡性能与效率
- 超长上下文:支持256k tokens上下文长度,轻松处理大型项目和复杂证明
- 多模态输入:接受文本和图像输入,生成文本输出,拓展应用场景
这些特性使得Leanstral-1.5-119B-A6B能够处理从简单代码补全到复杂数学证明的各种任务,为Lean 4开发者提供了全方位的支持。
推荐配置:优化你的Leanstral体验 ⚙️
为了获得最佳的使用体验,建议使用以下配置:
- 温度设置:1.0,平衡创造性和准确性
- 推理努力:
'none'→ 不使用推理,适合简单任务'high'→ 使用推理,推荐用于复杂提示
- 上下文长度:建议≤200k tokens,确保最佳性能
这些设置可以根据具体任务需求进行调整,以获得最理想的结果。
快速上手:安装与使用指南 📚
安装Mistral Vibe和Leanstral
如果你已经安装了Leanstral,它应该会自动使用新模型。如果没有,请按照以下步骤操作:
验证你的Mistral账户设置:
- 访问 https://chat.mistral.ai/ 注册或登录
- 你可以使用免费计划(无需订阅Mistral Pro)
- 在 https://admin.mistral.ai/plateforme/privacy 中选择"启用实验室模型"
- 在 https://admin.mistral.ai/organization/api-keys 创建API密钥
按照说明安装mistral vibe CLI:https://docs.mistral.ai/getting-started/quickstarts/vibe-code/install-cli
安装完成后,设置应该会自动进行,请求你的API密钥。如果没有,请在终端中使用
vibe --setup在Mistral
vibe中设置Leanstral:- 输入
/leanstall(lean + install) - 输入
exit退出vibe
- 输入
使用Leanstral
安装完成后,你可以通过以下步骤使用Leanstral:
在终端中输入
vibe --agent lean(确保顶部显示Leanstral)- 建议在VS Code终端中运行
vibe,以便同时查看vibe和你的代码 - 建议在Lean项目目录中运行
vibe - 要自动批准模型更改(谨慎使用!),使用
vibe --agent lean --yolo
- 建议在VS Code终端中运行
让Leanstral执行任何编码任务,例如证明给定的定理或修复项目中的代码
Leanstral能够处理需要数小时工作的长程任务,不要犹豫让它解决复杂问题
与lean-lsp-mcp一起使用
我们建议将Leanstral与lean-lsp-mcp一起使用,这是AI代理与Lean交互的标准工具。lean-lsp-mcp的README中有关于如何将MCP与Mistral Vibe一起设置的说明。
本地部署:打造你的专属Leanstral服务 🏠
如果你不想使用Mistral API,而是想使用本地vLLM服务器,可以按照以下步骤操作:
本地服务器设置
按照
Usage - vllm中的说明启动vllm服务器在
~/.vibe/agents中创建一个新的代理文件lean.toml:
mkdir ~/.vibe/agents/ && touch ~/.vibe/agents/lean.toml- 将以下配置复制粘贴到
~/.vibe/agents/lean.toml中:
display_name = "Lean (local vLLM)" description = "Lean 4 mode using local vLLM" safety = "neutral" system_prompt_id = "lean" active_model = "leanstral" [[providers]] name = "vllm" api_base = "http://<your-host-url>:8000/v1" api_key_env_var = "" backend = "generic" reasoning_field_name = "reasoning_content" [[models]] name = "mistralai/Leanstral-1.5-119B-A6B" provider = "vllm" alias = "leanstral" thinking = "high" temperature = 1.0 auto_compact_threshold = 168000 [tools.bash] default_timeout = 1200注意:确保将<your-host-url>替换为你的服务器URL。
- 重新启动
vibe并"tab-shift"到"lean"模式。
尝试在一些"lean"代码上使用它,例如:PrimeNumberTheoremAnd
使用vLLM部署
该模型也可以使用vLLM部署,如果你发现本地服务的模型性能不佳,我们建议使用Mistral AI API:
步骤1:安装vLLM
确保安装vllm >= 0.24.0:
uv pip install -U vllm --torch-backend=auto这应该会自动安装mistral_common >= 1.11.5。
检查安装:
python -c "import mistral_common; print(mistral_common.__version__)"你也可以使用现成的docker镜像或docker hub。
步骤2:启动服务器
我们建议在服务器/客户端设置中使用Leanstral。
vllm serve mistralai/Leanstral-1.5-119B-A6B \ --max-model-len 200000 \ --tensor-parallel-size 4 \ --attention-backend FLASH_ATTN_MLA \ --tool-call-parser mistral \ --enable-auto-tool-choice \ --reasoning-parser mistral步骤3:使用客户端
from openai import OpenAI from huggingface_hub import hf_hub_download # 修改OpenAI的API密钥和API库以使用vLLM的API服务器 openai_api_key = "EMPTY" openai_api_base = "<your-host-url>" client = OpenAI( api_key=openai_api_key, base_url=openai_api_base, ) TEMP = 1.0 MAX_TOK = 32000 REASONING = "high" # 切换到'none'以获得更快的答案 models = client.models.list() model = models.data[0].id prompt = """将转换规则定义为归纳命题。 这种选择为证明有关有效转换的属性提供了更好的支持,并且通常更自然地用于在Lean中建模状态机,你想要表达逻辑规则而不仅仅是为每个可能的转换计算是/否值。""" messages = [ { "role": "user", "content": [ { "type": "text", "text": prompt, }, ], }, ] response = client.chat.completions.create( model=model, messages=messages, temperature=TEMP, max_tokens=MAX_TOK, reasoning_effort=REASONING, ) print("内容") print(response.choices[0].message.content) print("推理过程") print(response.choices[0].message.reasoning)工具调用:扩展Leanstral的能力 🛠️
你可以向聊天完成添加工具,如下所示:
prompt = """我有以下Lean 4代码片段,想检查它是否能够编译和运行而没有错误。你能帮我运行它并告诉我结果吗? ```lean inductive State where | idle | busy | error def transition : State → State → Bool | .idle, .busy => true | .busy, .idle => true | .busy, .error => true | _, _ => false #eval transition .idle .busy ```""" tools = [{ "type": "function", "function": { "name": "lean_run_code", "description": "运行或编译独立的Lean代码片段或文件,并返回结果或错误消息。", "parameters": { "type": "object", "properties": { "code": { "type": "string", "description": "要运行或编译的Lean代码片段。必须提供此参数或file_path。" }, "file_path": { "type": "string", "description": "要运行或编译的Lean文件的路径。必须提供此参数或code。" } }, } } }] messages = [ { "role": "user", "content": [ { "type": "text", "text": prompt, }, ], }, ] response = client.chat.completions.create( model=model, messages=messages, temperature=TEMP, max_tokens=MAX_TOK, reasoning_effort=REASONING, tools=tools, ) print("工具调用") print(response.choices[0].message.tool_calls) print("推理过程") print(response.choices[0].message.reasoning)获取模型:开始你的Leanstral之旅 🚀
要开始使用Leanstral-1.5-119B-A6B,你可以通过以下命令克隆仓库:
git clone https://gitcode.com/hf_mirrors/mistralai/Leanstral-1.5-119B-A6B许可证信息 📄
本模型采用Apache 2.0许可证。
你不得将此模型用于侵犯、盗用或以其他方式违反任何第三方权利(包括知识产权)的行为。
Leanstral-1.5-119B-A6B为Lean 4开发者提供了一个强大而灵活的AI助手,无论是处理日常编码任务还是解决复杂的数学证明,它都能成为你不可或缺的工具。立即开始你的Leanstral之旅,体验AI驱动的编程新方式!
【免费下载链接】Leanstral-1.5-119B-A6B项目地址: https://ai.gitcode.com/hf_mirrors/mistralai/Leanstral-1.5-119B-A6B
创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考