{"id":22706165,"url":"https://github.com/a-tokyo/ai-zero-shot-classifier","last_synced_at":"2025-04-12T11:08:33.322Z","repository":{"id":267206351,"uuid":"900054854","full_name":"a-tokyo/ai-zero-shot-classifier","owner":"a-tokyo","description":"🧠 leverage advanced AI embeddings to perform multilingual zero-shot text classification. Whether you're dealing with unlabelled data or seeking to classify text against dynamic and user-defined labels, this library provides a seamless and efficient solution.","archived":false,"fork":false,"pushed_at":"2025-04-11T00:39:26.000Z","size":1166,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-11T01:30:38.916Z","etag":null,"topics":["ai","artificial-intelligence","classifier","deep-learning","groq","llama","llm","machine-learning","multilingual","nlp","no-fine-tuning","nodejs","ollama","openai","react","react-native","vector-similarity","vue","zero-shot"],"latest_commit_sha":null,"homepage":"https://a-tokyo.github.io/ai-zero-shot-classifier","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/a-tokyo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":["a-tokyo"],"buy_me_a_coffee":"ahmedtokyo"}},"created_at":"2024-12-07T18:32:33.000Z","updated_at":"2025-04-11T00:37:37.000Z","dependencies_parsed_at":null,"dependency_job_id":"bfe3548e-e975-42b3-80cf-4c16ea2fcd2b","html_url":"https://github.com/a-tokyo/ai-zero-shot-classifier","commit_stats":null,"previous_names":["a-tokyo/ai-zero-shot-classifier"],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a-tokyo%2Fai-zero-shot-classifier","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a-tokyo%2Fai-zero-shot-classifier/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a-tokyo%2Fai-zero-shot-classifier/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a-tokyo%2Fai-zero-shot-classifier/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/a-tokyo","download_url":"https://codeload.github.com/a-tokyo/ai-zero-shot-classifier/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248326965,"owners_count":21085175,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","artificial-intelligence","classifier","deep-learning","groq","llama","llm","machine-learning","multilingual","nlp","no-fine-tuning","nodejs","ollama","openai","react","react-native","vector-similarity","vue","zero-shot"],"created_at":"2024-12-10T10:07:39.898Z","updated_at":"2025-04-12T11:08:33.300Z","avatar_url":"https://github.com/a-tokyo.png","language":"TypeScript","funding_links":["https://github.com/sponsors/a-tokyo","https://buymeacoffee.com/ahmedtokyo"],"categories":[],"sub_categories":[],"readme":"\n# ai-zero-shot-classifier\n\n\u003ca href=\"https://npmjs.com/package/ai-zero-shot-classifier\"\u003e\n  \u003cimg src=\"https://img.shields.io/npm/v/ai-zero-shot-classifier.svg\"\u003e\u003c/img\u003e\n  \u003cimg src=\"https://img.shields.io/npm/dt/ai-zero-shot-classifier.svg\"\u003e\u003c/img\u003e\n\u003c/a\u003e\n\u003ca href=\"https://codecov.io/gh/A-Tokyo/ai-zero-shot-classifier\"\u003e\n  \u003cimg src=\"https://img.shields.io/codecov/c/github/a-tokyo/ai-zero-shot-classifier.svg\"\u003e\u003c/img\u003e\n\u003c/a\u003e\n\u003ca href=\"https://twitter.com/intent/follow?screen_name=ahmad_tokyo\"\u003e\u003cimg src=\"https://img.shields.io/twitter/follow/ahmad_tokyo.svg?label=Follow%20@ahmad_tokyo\" alt=\"Follow @ahmad_tokyo\"\u003e\u003c/img\u003e\u003c/a\u003e\n\n[Checkout the demo for a quick start!](https://a-tokyo.github.io/ai-zero-shot-classifier)\n\n---\n\n## 🚀 Introduction\n\n**ai-zero-shot-classifier** is a powerful, flexible JavaScript library designed to perform zero-shot text classification using pre-trained AI embeddings. The library supports multiple providers and models, enabling you to choose the best AI tools for your project, whether it's OpenAI's models or alternative providers like Groq.\n\n---\n\n## 🧐 Why ai-zero-shot-classifier?\n\n### **The Problem**\nTraditional text classification requires extensive labeled data and retraining models to adapt to new categories. This process can be costly, time-consuming, and impractical when dealing with constantly evolving datasets or dynamic categories.\n\n### **The Innovation**\n**ai-zero-shot-classifier** eliminates the need for labeled datasets by leveraging pre-trained AI embeddings. It allows for dynamic and task-specific labels, enabling real-time classification across various domains without retraining models. It supports multiple providers and their respective models, making it adaptable to diverse use cases.\n\n---\n\n## ✨ Features\n\n- **Multi-Provider Support**: Works with providers like OpenAI and Groq, enabling integration with models such as GPT, Llama, and others.\n- **Dynamic Labels**: Define your labels dynamically for each classification task.\n- **Multiple Similarity Functions**: Supports cosine similarity, dot product, and Euclidean distance for flexible classification needs.\n- **Batch Processing**: Efficiently handles large datasets with customizable batch sizes and concurrency.\n- **Highly Configurable**: Adjustable settings for embeddings, similarity calculations, and more.\n- **Seamless Integration**: Simple API designed for easy use in Node.js and browser environments.\n\n---\n\n## 📦 Installation\n\n```bash\nnpm install ai-zero-shot-classifier\n```\n\nor\n\n```bash\nyarn add ai-zero-shot-classifier\n```\n\n---\n\n## 🚀 Usage\n\n### Basic Example with classify Function\n\n```javascript\nimport { classify } from 'ai-zero-shot-classifier';\n\nconst labels = ['Technology', 'Health', 'Finance'];\nconst data = [\n  'Artificial Intelligence is transforming industries.',\n  'The stock market has seen unprecedented growth.',\n  'Healthcare advancements are improving lives.'\n];\n\nclassify({ labels, data, config: { similarity: 'cosine' } })\n  .then((results) =\u003e {\n    console.log(results);\n  })\n  .catch((error) =\u003e {\n    console.error(error);\n  });\n```\n\n### Example with ZeroShotClassifier Class\n\n```javascript\nimport ZeroShotClassifier from 'ai-zero-shot-classifier';\n\nconst labels = ['Technology', 'Health', 'Finance'];\nconst data = [\n  'Artificial Intelligence is transforming industries.',\n  'The stock market has seen unprecedented growth.',\n  'Healthcare advancements are improving lives.'\n];\n\n// Create an instance of the classifier\nconst classifier = new ZeroShotClassifier({\n  provider: 'openai', // Specify the provider\n  model: 'text-embedding-3-small', // Specify the model\n  apiKey: 'your-api-key', // API key for authentication\n  labels, // Provide labels for classification\n  dimensions: undefined, // Pass dimensions as a number here to configure vector dimensions\n});\n\n(async () =\u003e {\n  try {\n    const results = await classifier.classify(data, {\n      similarity: 'cosine', // Choose the similarity metric\n    });\n\n    // perform more classification\n\n    console.log('Classification Results:', results);\n  } catch (error) {\n    console.error('Error during classification:', error);\n  }\n})();\n```\n\n---\n\n## ⚙️ Configuration Options\n\n| Option                     | Description                                       | Default          |\n|----------------------------|---------------------------------------------------|------------------|\n| `similarity`               | Similarity function to use (`cosine`, `dot`, `euclidean`) | `cosine`         |\n| `embeddingBatchSizeData`   | Batch size for data embeddings                    | `50`             |\n| `embeddingBatchSizeLabels` | Batch size for label embeddings                   | `50`             |\n| `embeddingConcurrencyData` | Concurrency for data embeddings                   | `5`              |\n| `embeddingConcurrencyLabels` | Concurrency for label embeddings                | `5`              |\n| `comparingConcurrencyTop`  | Concurrency for top-level comparisons             | `10`             |\n| `comparingConcurrencyBottom` | Concurrency for bottom-level comparisons        | `10`             |\n\n---\n\n## 🛠️ Development\n\nClone the repository:\n\n```bash\ngit clone https://github.com/a-tokyo/ai-zero-shot-classifier.git\n```\n\nInstall dependencies:\n\n```bash\nyarn install\n```\n\nRun the development server:\n\n```bash\nyarn start\n```\n\nRun tests:\n\n```bash\nyarn test\n```\n\n---\n\n## 🤝 Contributing\n\nContributions are welcome! Feel free to open issues or submit pull requests.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fa-tokyo%2Fai-zero-shot-classifier","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fa-tokyo%2Fai-zero-shot-classifier","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fa-tokyo%2Fai-zero-shot-classifier/lists"}