GitHub repo xịn · Vui Coding chọn
cactus-compute/needle
Repo này cung cấp mẫu foundation nhỏ gọn 14MB cho thiết bị giới hạn như điện thoại, wearables, nhà thông minh và robot, giúp gọi công cụ và trích xuất dữ liệu có cấu trúc một cách hiệu quả. Nó hỗ trợ inference, fine-tuning bằng LoRA và xuất model dễ dàng qua Python.
Tóm tắt nhanh
Repo này làm được gì?
Repo này cung cấp mẫu foundation nhỏ gọn 14MB cho thiết bị giới hạn như điện thoại, wearables, nhà thông minh và robot, giúp gọi công cụ và trích xuất dữ liệu có cấu trúc một cách hiệu quả. Nó hỗ trợ inference, fine-tuning bằng LoRA và xuất model dễ dàng qua Python.
Mô tả từ GitHub
14MB foundation model for tiny devices; phones, wearables, smart home, and robots.
Bắt đầu với repo
Cài đặt và sử dụng
Hướng dẫn cài đặt
1. Cài đặt package bằng lệnh:
pip install cactus-needle2. Để dùng fine-tuning hoặc xuất checkpoint, cài:
pip install "cactus-needle[train]"Hướng dẫn sử dụng
1. Để gọi tool trong Python:
import needle
def get_weather(city: str):
"Get the current weather for a city."
return {"city": city, "temp_c": 27, "sky": "clear"}
agent = needle.Needle(tools=[get_weather])
print(agent.run("what's it like in Lagos right now?")["results"])2. Để trích xuất dữ liệu cấu trúc:
from pydantic import BaseModel
class Invoice(BaseModel):
vendor: str
total: float
due_date: str
invoice = needle.extract("Invoice from Acme Corp, $1,200.00, due 2026-09-01", Invoice)
print(invoice.vendor, invoice.total)