Token导航 LogoToken导航TokenDH.com
研究检索敏感数据github未标认证来源可访问clear审计通过

train-fasttext训练快速文本

Agent Skill

train-fasttext 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

808

周安装

34

GitHub Stars

93

下载量

283
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

3

许可证

MIT

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:train-fasttext(训练快速文本)
来源仓库:https://github.com/letta-ai/skills
仓库路径:skills/train-fasttext
安装命令:
npx skills add https://github.com/letta-ai/skills --skill train-fasttext
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。不同来源提供的安装方式可能略有差异;本站展示可直接复制的安装命令,安装前请核对来源页面。

skills.shnpx skills
npx skills add https://github.com/letta-ai/skills --skill train-fasttext

简介

用于训练轻量级词向量模型,支持文本分类、相似度计算等 NLP 任务。

  • 可自定义语料库与超参数,输出可用于下游任务的 embedding 文件。
  • 通过脚本封装训练流程,降低深度学习门槛,适合中小规模数据集。
  • 训练过程消耗较多 CPU/GPU 资源,建议在专用机器上运行并监控进度。
  • 当前无参数说明,建议查阅 fasttext 官方指南并结合本封装调整配置。

SKILL.md

Train FastText

Overview

This skill provides guidance for training FastText text classification models, particularly when facing dual constraints like model size limits and accuracy requirements. It covers systematic experimentation strategies, hyperparameter tuning approaches, and common pitfalls to avoid.

Constraint Prioritization Strategy

When facing competing constraints (e.g., model size < X MB AND accuracy >= Y%), establish a clear strategy:

  1. Identify which constraint is harder to satisfy - Accuracy is typically harder to recover after compression
  2. First achieve the accuracy target with an unconstrained model
  3. Then apply size reduction techniques (quantization, dimension reduction, pruning)
  4. Track the accuracy-size trade-off at each compression step

Systematic Experimentation Approach

Phase 1: Quick Exploratory Runs

Before committing to long training times, run quick experiments to understand parameter sensitivity:

# Quick baseline (1-2 minutes)
model = fasttext.train_supervised(
    input=train_file,
    dim=50,
    epoch=5,
    lr=0.5
)

Record results systematically:

  • Accuracy on validation set
  • Model file size
  • Training time

Phase 2: Parameter Sensitivity Analysis

Test one parameter at a time while holding others constant:

ParameterLowMediumHighImpact
dim50100200Size, accuracy
epoch51525Training time, accuracy
lr0.10.51.0Convergence speed
wordNgrams123Accuracy, size

Phase 3: Targeted Optimization

Based on Phase 2 findings, combine the best parameters and fine-tune.

Key FastText Parameters

Accuracy-Focused Parameters

  • dim: Word vector dimensions (higher = more expressive, larger model)
  • epoch: Training iterations (more epochs can improve accuracy, diminishing returns)
  • wordNgrams: N-gram features (2 or 3 often improves accuracy significantly)
  • lr: Learning rate (higher can speed convergence but may overshoot)
  • loss: Loss function (softmax for few classes, ova for many classes, ns for very large label spaces)

Size-Focused Parameters

  • dim: Lower dimensions = smaller model
  • bucket: Hash bucket size for n-grams (lower = smaller model, may hurt accuracy)
  • minCount: Minimum word frequency (higher = smaller vocabulary)
  • minn/maxn: Character n-gram range (0,0 disables, reduces size)

Model Compression Techniques

Quantization

FastText quantization can dramatically reduce model size (often 4-10x reduction):

model.quantize(input=train_file, retrain=True)
model.save_model("model.ftz")

Important trade-off: Quantization typically reduces accuracy by 1-5%. Plan for this when targeting accuracy thresholds.

When to Apply Quantization

  • If non-quantized model is close to size limit (e.g., 155MB vs 150MB limit), try parameter tuning first
  • If non-quantized model is far above limit, quantization is necessary
  • Always measure accuracy before and after quantization

Built-in Optimization Features

Autotune (Recommended)

FastText's autotune automatically searches for optimal hyperparameters:

model = fasttext.train_supervised(
    input=train_file,
    autotuneValidationFile=valid_file,
    autotuneDuration=600,  # seconds
    autotuneModelSize="150M"  # target size constraint
)

This is often more effective than manual parameter tuning.

Verification Strategies

1. Create a Validation Set

Reserve 10-20% of training data for validation. Do not rely solely on test set evaluation:

# Split data
shuf train.txt > shuffled.txt
head -n 80000 shuffled.txt > train_split.txt
tail -n 20000 shuffled.txt > valid_split.txt

2. Verify Model File Integrity

Before evaluation, verify the model file is valid:

import os
import fasttext

# Check file exists and has reasonable size
model_path = "/app/model.bin"
if os.path.exists(model_path):
    size_mb = os.path.getsize(model_path) / (1024 * 1024)
    print(f"Model size: {size_mb:.2f} MB")

    # Try loading to verify integrity
    model = fasttext.load_model(model_path)
    print(f"Labels: {len(model.labels)}")

3. Monitor Training Progress

For long-running training, implement progress monitoring:

import time

start_time = time.time()
model = fasttext.train_supervised(input=train_file, epoch=25, verbose=2)
elapsed = time.time() - start_time
print(f"Training completed in {elapsed:.1f} seconds")

Common Pitfalls to Avoid

1. Random Parameter Changes

Problem: Changing multiple parameters simultaneously without tracking impact.

Solution: Change one parameter at a time and record results in a structured log.

2. Premature Quantization

Problem: Always applying quantization regardless of whether it's needed.

Solution: Check if non-quantized model meets size constraint first. Minor parameter adjustments may achieve size goals with less accuracy loss than quantization.

3. Inadequate Time Estimation

Problem: Setting training timeouts too short for the chosen parameters.

Solution: Estimate training time based on:

  • Dataset size (lines × epoch count)
  • Previous run times with similar parameters
  • Add 50% buffer for safety

4. No Checkpoint Strategy

Problem: Losing good intermediate results when training is interrupted.

Solution: Save intermediate models and track their performance:

for epoch in [5, 10, 15, 20, 25]:
    model = fasttext.train_supervised(input=train_file, epoch=epoch)
    acc = evaluate(model, valid_file)
    model.save_model(f"model_epoch{epoch}.bin")
    print(f"Epoch {epoch}: accuracy={acc}")

5. Overwriting Best Models

Problem: New training runs overwrite previous better models.

Solution: Use timestamped or versioned model names:

import datetime
timestamp = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
model.save_model(f"model_{timestamp}.bin")

6. Ignoring Text Preprocessing

Problem: Training on raw text without preprocessing.

Solution: Consider preprocessing steps:

  • Lowercasing
  • Removing special characters
  • Normalizing whitespace
  • Optional: removing stop words

Decision Flowchart

START
  │
  ▼
Run quick baseline (dim=50, epoch=5)
  │
  ▼
Does baseline meet accuracy target?
  │
  ├─ YES → Check size constraint
  │         ├─ Meets size → DONE
  │         └─ Exceeds size → Apply quantization or reduce dim
  │
  └─ NO → Increase model capacity
           │
           ▼
         Try: higher dim, more epochs, wordNgrams=2
           │
           ▼
         Does improved model meet accuracy?
           ├─ YES → Check size, apply compression if needed
           └─ NO → Try autotune with validation file

Environment Setup Best Practice

Avoid repeating environment setup in every command. Set up once at the start:

# Set up environment variables in shell profile or script
export PATH="$HOME/.local/bin:$PATH"
cd /app

# Or create a wrapper script

Summary Checklist

Before starting training:

  • Create validation split from training data
  • Plan systematic parameter exploration
  • Estimate training time for parameters
  • Set up model versioning/checkpointing

During training:

  • Track all experiments (parameters, accuracy, size, time)
  • Change one parameter at a time
  • Save promising intermediate models

After training:

  • Verify model file integrity
  • Test on validation set
  • Apply compression only if needed
  • Verify final model meets all constraints

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

04

需要参考平台分布和安装热度时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

补充不同宿主或平台的使用分布数据

能力 5

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Claude Code

27.22%
按下载量换算77

Gemini CLI

23.02%
按下载量换算65

Codex

18.53%
按下载量换算52

Antigravity

13.85%
按下载量换算39

OpenCode

7.46%
按下载量换算21

windsurf

3.75%
按下载量换算11

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

敏感数据

该 Skill 可能接触密钥、Token、环境变量或敏感配置,应进入高风险复核队列,默认不自动发布。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。

来源信息

继续浏览同类 Skills