npx skills add smithery/pluginagentmarketplace --skill llm-basics
pluginagentmarketplace/custom-plugin-ai-engineer · Archived
llm-basics
LLM architecture, tokenization, transformers, and inference optimization. Use for understanding and working with language models.
Installation
npx skills add pluginagentmarketplace/custom-plugin-ai-engineer --skill llm-basics
Stronger alternatives
This repository is archived — consider an actively maintained alternative.
Vector database selection, indexing strategies, and semantic search optimization.
6 installsPrompt design, optimization, few-shot learning, and chain of thought techniques for LLM applica…
6 installsLLM deployment strategies including vLLM, TGI, and cloud inference endpoints.
5 installsLLM fine-tuning with LoRA, QLoRA, and instruction tuning for domain adaptation.
5 installsSimilar popular skills
Related neighbors and high-traction skills in the same topics — useful to compare before installing.
Helps users discover and install agent skills when they ask questions like "how do I do X", "fi…
3.3M installsBrowser automation CLI for AI agents. Use when the user needs to interact with websites, includ…
810.4K installsReview UI code for Web Interface Guidelines compliance. Use when asked to "review my UI", "chec…
617.3K installsBuild, deploy, evaluate, optimize, fine-tune, and manage Microsoft Foundry agents, models, and …
576.5K installsPrepare azd-based Azure projects for deployment: generates azure.yaml, infrastructure (Bicep/Te…
568.3K installsAlso in this package
Other skills from pluginagentmarketplace/custom-plugin-ai-engineer.
npx skills add pluginagentmarketplace/custom-plugin-ai-engineer
Browse all from pluginagentmarketplace/custom-plugin-ai-engineer
More details
Agent compatibility
Declared targets from SKILL.md / docs. Unmarked agents are not listed — the skill may still install via the CLI.
Also listed on
Alternate registries and mirrors of this skill.
Repository health
main
Package contents
Files included with this skill beyond the listing page.
-
skill md
SKILL.md4,373 B -
docs
SUMMARY.md147 B
History
- First seen on skills.sh
- First recorded snapshot · 5 installs
SKILL.md
LLM Basics
Master the fundamentals of Large Language Models.
Quick Start
Using OpenAI API
from openai import OpenAI
client = OpenAI()
response = client.chat.completions.create(
model="gpt-4",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Explain transformers briefly."}
],
temperature=0.7,
max_tokens=500
)
print(response.choices[0].message.content)
Using Hugging Face
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch
model_name = "meta-llama/Llama-2-7b-hf"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(model_name)
inputs = tokenizer("Hello, how are", return_tensors="pt")
outputs = model.generate(**inputs, max_new_tokens=50)
print(tokenizer.decode(outputs[0]))
Core Concepts
Transformer Architecture
Input → Embedding → [N × Transformer Block] → Output
Transformer Block:
┌───────────────────────────┐
│ Multi-Head Self-Attention │
├───────────────────────────┤
│ Layer Normalization │
├───────────────────────────┤
│ Feed-Forward Network │
├───────────────────────────┤
│ Layer Normalization │
└───────────────────────────┘
Tokenization
from transformers import AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained("gpt2")
text = "Hello, world!"
# Encode
tokens = tokenizer.encode(text)
print(tokens) # [15496, 11, 995, 0]
# Decode
decoded = tokenizer.decode(tokens)
print(decoded) # "Hello, world!"
Key Parameters
# Generation parameters
params = {
'temperature': 0.7, # Randomness (0-2)
'max_tokens': 1000, # Output length limit
'top_p': 0.9, # Nucleus sampling
'top_k': 50, # Top-k sampling
'frequency_penalty': 0, # Reduce repetition
'presence_penalty': 0 # Encourage new topics
}
Model Comparison
| Model | Parameters | Context | Best For |
|---|---|---|---|
| GPT-4 | ~1.7T | 128K | Complex reasoning |
| GPT-3.5 | 175B | 16K | General tasks |
| Claude 3 | N/A | 200K | Long context |
| Llama 2 | 7-70B | 4K | Open source |
| Mistral 7B | 7B | 32K | Efficient inference |
Local Inference
With Ollama
# Install Ollama
curl -fsSL https://ollama.ai/install.sh | sh
# Run a model
ollama run llama2
# API usage
curl http://localhost:11434/api/generate -d '{
"model": "llama2",
"prompt": "Why is the sky blue?"
}'
With vLLM
from vllm import LLM, SamplingParams
llm = LLM(model="meta-llama/Llama-2-7b-hf")
sampling = SamplingParams(temperature=0.8, max_tokens=100)
outputs = llm.generate(["Hello, my name is"], sampling)
Best Practices
- Start simple: Use API before local deployment
- Mind context: Stay within context window limits
- Temperature tuning: Lower for facts, higher for creativity
- Token efficiency: Shorter prompts = lower costs
- Streaming: Use for better UX in applications
Error Handling & Retry
from tenacity import retry, stop_after_attempt, wait_exponential
@retry(stop=stop_after_attempt(3), wait=wait_exponential(min=1, max=10))
def call_llm_with_retry(prompt: str) -> str:
return client.chat.completions.create(...)
Troubleshooting
| Symptom | Cause | Solution |
|---|---|---|
| Rate limit errors | Too many requests | Add exponential backoff |
| Empty response | max_tokens=0 | Check parameter values |
| High latency | Large model | Use smaller model |
| Timeout | Prompt too long | Reduce input size |
Unit Test Template
def test_llm_completion():
response = call_llm("Hello")
assert response is not None
assert len(response) > 0