scikit-llm

fnnx-aiMIT活跃维护

把大语言模型包装成 scikit-learn 风格的估计器,让文本分类、标注等任务能直接套用 fit/predict 和 Pipeline,省去自己写调用逻辑。

Seamlessly integrate LLMs into scikit-learn.

v1.4.3发布于 2026-01-21 13:57 UTC3,540star287fork同步于 2026-11-10 17:42 UTC

怎么上手

由 README 提炼,执行前请确认
pip install scikit-llm
硬件要求按 README 说明

README 未说明,仅通过 API 调用 GPT 模型,未提及本地显存或 GPU 要求

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

把 ChatGPT 等大模型封装成 scikit-learn 估计器,让文本分类等任务沿用 fit/predict 流程

把大语言模型包装成 scikit-learn 风格的估计器,让文本分类、标注等任务能直接套用 fit/predict 和 Pipeline,省去自己写调用逻辑。

核心能力

  • 提供 ZeroShotGPTClassifier 等 sklearn 风格估计器
  • 用 fit/predict 接口调用 GPT 模型做文本分类
  • 通过 SKLLMConfig 统一配置 OpenAI 密钥与组织 ID
  • 内置演示数据集 get_classification_dataset 便于快速上手

容易踩的坑

需要自备 OpenAI API Key 和组织 ID 并先调用 SKLLMConfig 配置;示例默认使用 gpt-4 模型,需确认账号有对应模型权限;README 未说明离线或本地模型支持

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本v1.4.3
  1. v1.4.3最新正式版2026-01-21 · 2026-01-21 13:57 UTC

    Changes

    • Fix prompt typo templates.py (#125)
    • Remove debug print statement and bump to v1.4.3 (#129)

    🧹 Maintenance

    • Bump peter-evans/create-pull-request from 6 to 7 (#116)
  2. v1.4.22025-09-20 · 2025-09-20 19:36 UTC
    查看更新说明

    Changes

    🚀 Features

    • Added model constants file and standardize model name usage (#124)
    • Added Anthropic API support (#118)
    • Added support for reasoning models/gpt-5
  3. v1.4.12024-11-09 · 2024-11-09 20:57 UTC
    查看更新说明

    Changes

    • Fixed labels extraction for multi-label classifiers (#117)
  4. v1.4.02024-08-04 · 2024-08-04 20:11 UTC
    查看更新说明

    Changes

    • Replaced gpt4all with llama-cpp-python (#110)
  5. v1.3.12024-07-24 · 2024-07-24 19:12 UTC
    查看更新说明

    Changes

    • Added gpt-4o-mini to the list of tunable models (#108)

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    Scikit-LLM: Scikit-Learn Meets Large Language Models

    Seamlessly integrate powerful language models like ChatGPT into scikit-learn for enhanced text analysis tasks.

    Installation 💾

    pip install scikit-llm
    

    Support us 🤝

    You can support the project in the following ways:

    • ⭐ Star Scikit-LLM on GitHub (click the star button in the top right corner)
    • 💡 Provide your feedback or propose ideas in the issues section or Discord
    • 📰 Post about Scikit-LLM on LinkedIn or other platforms
    • 🔗 Check out our other projects: Dingo, Falcon

    Quick Start & Documentation 📚

    Quick start example of zero-shot text classification using GPT:

    # Import the necessary modules
    from skllm.datasets import get_classification_dataset
    from skllm.config import SKLLMConfig
    from skllm.models.gpt.classification.zero_shot import ZeroShotGPTClassifier
    
    # Configure the credentials
    SKLLMConfig.set_openai_key("<YOUR_KEY>")
    SKLLMConfig.set_openai_org("<YOUR_ORGANIZATION_ID>")
    
    # Load a demo dataset
    X, y = get_classification_dataset() # labels: positive, negative, neutral
    
    # Initialize the model and make the predictions
    clf = ZeroShotGPTClassifier(model="gpt-4")
    clf.fit(X,y)
    clf.predict(X)
    

    For more information please refer to the documentation.

    Citation

    You can cite Scikit-LLM using the following BibTeX:

    @software{ScikitLLM,
      author = {Iryna Kondrashchenko and Oleh Kostromin},
      year = {2023},
      publisher = {beastbyte.ai},
      address = {Linz, Austria},
      title = {Scikit-LLM: Scikit-Learn Meets Large Language Models},
      url = {https://github.com/iryna-kondr/scikit-llm }
    }