
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
ai-zero-shot-classifier
Advanced tools
🧠 powerful JavaScript library that leverages advanced AI embeddings to perform 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 seamles
Checkout the demo for a quick start!
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.
Traditional 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.
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.
npm install ai-zero-shot-classifier
or
yarn add ai-zero-shot-classifier
import { classify } from 'ai-zero-shot-classifier';
const labels = ['Technology', 'Health', 'Finance'];
const data = [
'Artificial Intelligence is transforming industries.',
'The stock market has seen unprecedented growth.',
'Healthcare advancements are improving lives.'
];
classify({ labels, data, config: { similarity: 'cosine' } })
.then((results) => {
console.log(results);
})
.catch((error) => {
console.error(error);
});
import ZeroShotClassifier from 'ai-zero-shot-classifier';
const labels = ['Technology', 'Health', 'Finance'];
const data = [
'Artificial Intelligence is transforming industries.',
'The stock market has seen unprecedented growth.',
'Healthcare advancements are improving lives.'
];
// Create an instance of the classifier
const classifier = new ZeroShotClassifier({
provider: 'openai', // Specify the provider
model: 'text-embedding-3-small', // Specify the model
apiKey: 'your-api-key', // API key for authentication
labels, // Provide labels for classification
dimensions: undefined, // Pass dimensions as a number here to configure vector dimensions
});
(async () => {
try {
const results = await classifier.classify(data, {
similarity: 'cosine', // Choose the similarity metric
});
// perform more classification
console.log('Classification Results:', results);
} catch (error) {
console.error('Error during classification:', error);
}
})();
Option | Description | Default |
---|---|---|
similarity | Similarity function to use (cosine , dot , euclidean ) | cosine |
embeddingBatchSizeData | Batch size for data embeddings | 50 |
embeddingBatchSizeLabels | Batch size for label embeddings | 50 |
embeddingConcurrencyData | Concurrency for data embeddings | 5 |
embeddingConcurrencyLabels | Concurrency for label embeddings | 5 |
comparingConcurrencyTop | Concurrency for top-level comparisons | 10 |
comparingConcurrencyBottom | Concurrency for bottom-level comparisons | 10 |
Clone the repository:
git clone https://github.com/a-tokyo/ai-zero-shot-classifier.git
Install dependencies:
npm install
Run the development server:
npm start
Run tests:
npm test
Checkout the demo for a quick start!
Contributions are welcome! Feel free to open issues or submit pull requests.
FAQs
🧠 powerful JavaScript library that leverages advanced AI embeddings to perform 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 seamles
The npm package ai-zero-shot-classifier receives a total of 25 weekly downloads. As such, ai-zero-shot-classifier popularity was classified as not popular.
We found that ai-zero-shot-classifier demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.