This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| classifier = pipeline("zero-shot-classification") | |
| text_to_classify = "I love my new blender! It makes smoothies so smooth." | |
| candidate_labels = ["electronics", "kitchen appliance", "sports equipment", "furniture"] | |
| result3 = classifier(text_to_classify, candidate_labels) | |
| print(result3) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| classifier = pipeline("sentiment-analysis") | |
| text = "I love sunny days." | |
| result = classifier(text) | |
| text2 = "I don't like the rain." | |
| result2 = classifier(text2) | |
| print("\n=== Sentiment Analysis ===") | |
| print(result) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| generator = pipeline("text-generation", model="gpt2") | |
| prompt = "Explain how self-driving cars work in simple terms." | |
| result = generator(prompt, max_length=50, num_return_sequences=1) | |
| print("=== Text Generation ===") | |
| print(result[0]['generated_text']) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from transformers import pipeline |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pip uninstall torch | |
| pip install torch --index-url https://download.pytorch.org/whl/cpu | |
| python3 -c "import numpy; print(numpy.__version__)" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pip install "numpy<2" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pip install transformers torch | |
| pip install "numpy<2" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| node index.js |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| touch index.js |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const nlpTools = require('natural'); | |
| const wordStore = ['cat', 'dog', 'elephant', 'giraffe']; | |
| const typoChecker = new nlpTools.Spellcheck(wordStore); | |
| console.log(typoChecker.getCorrections('elephnt', 2)); | |
| console.log(typoChecker.getCorrections('grffe', 2)); |
NewerOlder