fix: add eval-docs to root for HF static serving
Browse filesCo-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
eval-docs/api-design-principles.md
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# API Design Principles
|
| 2 |
+
|
| 3 |
+
## Introduction
|
| 4 |
+
|
| 5 |
+
Good API design is crucial for developer experience. This document outlines the core principles we follow when designing REST APIs.
|
| 6 |
+
|
| 7 |
+
## Principle 1: Use Nouns, Not Verbs
|
| 8 |
+
|
| 9 |
+
URLs should represent resources, not actions. Use HTTP methods to indicate the action.
|
| 10 |
+
|
| 11 |
+
**Good:**
|
| 12 |
+
- GET /users/123
|
| 13 |
+
- POST /orders
|
| 14 |
+
- DELETE /products/456
|
| 15 |
+
|
| 16 |
+
**Bad:**
|
| 17 |
+
- GET /getUser?id=123
|
| 18 |
+
- POST /createOrder
|
| 19 |
+
- GET /deleteProduct/456
|
| 20 |
+
|
| 21 |
+
## Principle 2: Use Plural Nouns
|
| 22 |
+
|
| 23 |
+
Always use plural nouns for consistency.
|
| 24 |
+
|
| 25 |
+
- /users (not /user)
|
| 26 |
+
- /orders (not /order)
|
| 27 |
+
- /products (not /product)
|
| 28 |
+
|
| 29 |
+
## Principle 3: Hierarchical Relationships
|
| 30 |
+
|
| 31 |
+
Express relationships through URL hierarchy.
|
| 32 |
+
|
| 33 |
+
- GET /users/123/orders - Get all orders for user 123
|
| 34 |
+
- GET /users/123/orders/456 - Get specific order 456 for user 123
|
| 35 |
+
|
| 36 |
+
## Principle 4: Filtering and Pagination
|
| 37 |
+
|
| 38 |
+
Use query parameters for filtering, sorting, and pagination.
|
| 39 |
+
|
| 40 |
+
- GET /products?category=electronics&sort=price&page=2&limit=20
|
| 41 |
+
|
| 42 |
+
## Principle 5: Versioning
|
| 43 |
+
|
| 44 |
+
Always version your APIs. We prefer URL versioning.
|
| 45 |
+
|
| 46 |
+
- /v1/users
|
| 47 |
+
- /v2/users
|
| 48 |
+
|
| 49 |
+
## Principle 6: Error Handling
|
| 50 |
+
|
| 51 |
+
Return consistent error responses with appropriate HTTP status codes.
|
| 52 |
+
|
| 53 |
+
```json
|
| 54 |
+
{
|
| 55 |
+
"error": {
|
| 56 |
+
"code": "VALIDATION_ERROR",
|
| 57 |
+
"message": "Email format is invalid",
|
| 58 |
+
"field": "email"
|
| 59 |
+
}
|
| 60 |
+
}
|
| 61 |
+
```
|
| 62 |
+
|
| 63 |
+
## Principle 7: Rate Limiting
|
| 64 |
+
|
| 65 |
+
Implement rate limiting and communicate limits via headers:
|
| 66 |
+
|
| 67 |
+
- X-RateLimit-Limit: 1000
|
| 68 |
+
- X-RateLimit-Remaining: 999
|
| 69 |
+
- X-RateLimit-Reset: 1640000000
|
| 70 |
+
|
| 71 |
+
## Conclusion
|
| 72 |
+
|
| 73 |
+
Following these principles leads to APIs that are intuitive, consistent, and easy to maintain. Remember: the best API is one that developers can use without reading documentation.
|
eval-docs/distributed-systems-overview.md
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Distributed Systems: A Practical Overview
|
| 2 |
+
|
| 3 |
+
## What Makes a System "Distributed"?
|
| 4 |
+
|
| 5 |
+
A distributed system is a collection of independent computers that appears to users as a single coherent system. The key challenges arise from:
|
| 6 |
+
|
| 7 |
+
1. **Partial failure** - Parts of the system can fail independently
|
| 8 |
+
2. **Unreliable networks** - Messages can be lost, delayed, or duplicated
|
| 9 |
+
3. **No global clock** - Different nodes have different views of time
|
| 10 |
+
|
| 11 |
+
## The CAP Theorem
|
| 12 |
+
|
| 13 |
+
Eric Brewer's CAP theorem states that a distributed system can only provide two of three guarantees:
|
| 14 |
+
|
| 15 |
+
- **Consistency**: All nodes see the same data at the same time
|
| 16 |
+
- **Availability**: Every request receives a response
|
| 17 |
+
- **Partition tolerance**: System continues operating despite network partitions
|
| 18 |
+
|
| 19 |
+
In practice, network partitions happen, so you're really choosing between CP and AP systems.
|
| 20 |
+
|
| 21 |
+
### CP Systems (Consistency + Partition Tolerance)
|
| 22 |
+
- Examples: ZooKeeper, etcd, Consul
|
| 23 |
+
- Sacrifice availability during partitions
|
| 24 |
+
- Good for: coordination, leader election, configuration
|
| 25 |
+
|
| 26 |
+
### AP Systems (Availability + Partition Tolerance)
|
| 27 |
+
- Examples: Cassandra, DynamoDB, CouchDB
|
| 28 |
+
- Sacrifice consistency during partitions
|
| 29 |
+
- Good for: high-throughput, always-on services
|
| 30 |
+
|
| 31 |
+
## Consensus Algorithms
|
| 32 |
+
|
| 33 |
+
When nodes need to agree on something, they use consensus algorithms.
|
| 34 |
+
|
| 35 |
+
### Paxos
|
| 36 |
+
- Original consensus algorithm by Leslie Lamport
|
| 37 |
+
- Notoriously difficult to understand and implement
|
| 38 |
+
- Foundation for many other algorithms
|
| 39 |
+
|
| 40 |
+
### Raft
|
| 41 |
+
- Designed to be understandable
|
| 42 |
+
- Used in etcd, Consul, CockroachDB
|
| 43 |
+
- Separates leader election from log replication
|
| 44 |
+
|
| 45 |
+
### PBFT (Practical Byzantine Fault Tolerance)
|
| 46 |
+
- Handles malicious nodes
|
| 47 |
+
- Used in blockchain systems
|
| 48 |
+
- Higher overhead than crash-fault-tolerant algorithms
|
| 49 |
+
|
| 50 |
+
## Replication Strategies
|
| 51 |
+
|
| 52 |
+
### Single-Leader Replication
|
| 53 |
+
- One node accepts writes
|
| 54 |
+
- Followers replicate from leader
|
| 55 |
+
- Simple but leader is bottleneck
|
| 56 |
+
|
| 57 |
+
### Multi-Leader Replication
|
| 58 |
+
- Multiple nodes accept writes
|
| 59 |
+
- Must handle write conflicts
|
| 60 |
+
- Good for multi-datacenter deployments
|
| 61 |
+
|
| 62 |
+
### Leaderless Replication
|
| 63 |
+
- Any node accepts writes
|
| 64 |
+
- Uses quorum reads/writes
|
| 65 |
+
- Examples: Dynamo-style databases
|
| 66 |
+
|
| 67 |
+
## Consistency Models
|
| 68 |
+
|
| 69 |
+
From strongest to weakest:
|
| 70 |
+
|
| 71 |
+
1. **Linearizability** - Operations appear instantaneous
|
| 72 |
+
2. **Sequential consistency** - Operations appear in some sequential order
|
| 73 |
+
3. **Causal consistency** - Causally related operations appear in order
|
| 74 |
+
4. **Eventual consistency** - Given enough time, all replicas converge
|
| 75 |
+
|
| 76 |
+
## Partitioning (Sharding)
|
| 77 |
+
|
| 78 |
+
Distributing data across nodes:
|
| 79 |
+
|
| 80 |
+
### Hash Partitioning
|
| 81 |
+
- Hash key to determine partition
|
| 82 |
+
- Even distribution
|
| 83 |
+
- Range queries are inefficient
|
| 84 |
+
|
| 85 |
+
### Range Partitioning
|
| 86 |
+
- Ranges of keys on different nodes
|
| 87 |
+
- Good for range queries
|
| 88 |
+
- Risk of hot spots
|
| 89 |
+
|
| 90 |
+
## Conclusion
|
| 91 |
+
|
| 92 |
+
Building distributed systems requires understanding these fundamental concepts. Start simple, add complexity only when needed, and always plan for failure.
|
eval-docs/machine-learning-primer.md
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Machine Learning: A Beginner's Guide
|
| 2 |
+
|
| 3 |
+
## What is Machine Learning?
|
| 4 |
+
|
| 5 |
+
Machine learning is a subset of artificial intelligence where systems learn patterns from data rather than being explicitly programmed. Instead of writing rules, you provide examples and let the algorithm discover the rules.
|
| 6 |
+
|
| 7 |
+
## Types of Machine Learning
|
| 8 |
+
|
| 9 |
+
### Supervised Learning
|
| 10 |
+
|
| 11 |
+
The algorithm learns from labeled examples.
|
| 12 |
+
|
| 13 |
+
**Classification**: Predicting categories
|
| 14 |
+
- Email spam detection
|
| 15 |
+
- Image recognition
|
| 16 |
+
- Medical diagnosis
|
| 17 |
+
|
| 18 |
+
**Regression**: Predicting continuous values
|
| 19 |
+
- House price prediction
|
| 20 |
+
- Stock price forecasting
|
| 21 |
+
- Temperature prediction
|
| 22 |
+
|
| 23 |
+
Common algorithms:
|
| 24 |
+
- Linear Regression
|
| 25 |
+
- Logistic Regression
|
| 26 |
+
- Decision Trees
|
| 27 |
+
- Random Forests
|
| 28 |
+
- Support Vector Machines (SVM)
|
| 29 |
+
- Neural Networks
|
| 30 |
+
|
| 31 |
+
### Unsupervised Learning
|
| 32 |
+
|
| 33 |
+
The algorithm finds patterns in unlabeled data.
|
| 34 |
+
|
| 35 |
+
**Clustering**: Grouping similar items
|
| 36 |
+
- Customer segmentation
|
| 37 |
+
- Document categorization
|
| 38 |
+
- Anomaly detection
|
| 39 |
+
|
| 40 |
+
**Dimensionality Reduction**: Simplifying data
|
| 41 |
+
- Feature extraction
|
| 42 |
+
- Visualization
|
| 43 |
+
- Noise reduction
|
| 44 |
+
|
| 45 |
+
Common algorithms:
|
| 46 |
+
- K-Means Clustering
|
| 47 |
+
- Hierarchical Clustering
|
| 48 |
+
- Principal Component Analysis (PCA)
|
| 49 |
+
- t-SNE
|
| 50 |
+
|
| 51 |
+
### Reinforcement Learning
|
| 52 |
+
|
| 53 |
+
The algorithm learns through trial and error, receiving rewards or penalties.
|
| 54 |
+
|
| 55 |
+
Applications:
|
| 56 |
+
- Game playing (AlphaGo, chess)
|
| 57 |
+
- Robotics
|
| 58 |
+
- Autonomous vehicles
|
| 59 |
+
- Resource management
|
| 60 |
+
|
| 61 |
+
## The Machine Learning Pipeline
|
| 62 |
+
|
| 63 |
+
1. **Data Collection**: Gather relevant data
|
| 64 |
+
2. **Data Cleaning**: Handle missing values, outliers
|
| 65 |
+
3. **Feature Engineering**: Create useful features
|
| 66 |
+
4. **Model Selection**: Choose appropriate algorithm
|
| 67 |
+
5. **Training**: Fit model to training data
|
| 68 |
+
6. **Evaluation**: Test on held-out data
|
| 69 |
+
7. **Deployment**: Put model into production
|
| 70 |
+
8. **Monitoring**: Track performance over time
|
| 71 |
+
|
| 72 |
+
## Key Concepts
|
| 73 |
+
|
| 74 |
+
### Overfitting vs Underfitting
|
| 75 |
+
|
| 76 |
+
**Overfitting**: Model memorizes training data, performs poorly on new data
|
| 77 |
+
- Solution: More data, regularization, simpler model
|
| 78 |
+
|
| 79 |
+
**Underfitting**: Model too simple to capture patterns
|
| 80 |
+
- Solution: More features, complex model, less regularization
|
| 81 |
+
|
| 82 |
+
### Train/Test Split
|
| 83 |
+
|
| 84 |
+
Never evaluate on training data. Common splits:
|
| 85 |
+
- 80% training, 20% testing
|
| 86 |
+
- 70% training, 15% validation, 15% testing
|
| 87 |
+
|
| 88 |
+
### Cross-Validation
|
| 89 |
+
|
| 90 |
+
K-fold cross-validation provides more robust evaluation:
|
| 91 |
+
1. Split data into K folds
|
| 92 |
+
2. Train on K-1 folds, test on remaining fold
|
| 93 |
+
3. Repeat K times
|
| 94 |
+
4. Average the results
|
| 95 |
+
|
| 96 |
+
### Bias-Variance Tradeoff
|
| 97 |
+
|
| 98 |
+
- **High Bias**: Oversimplified model (underfitting)
|
| 99 |
+
- **High Variance**: Overcomplicated model (overfitting)
|
| 100 |
+
- Goal: Find the sweet spot
|
| 101 |
+
|
| 102 |
+
## Evaluation Metrics
|
| 103 |
+
|
| 104 |
+
### Classification
|
| 105 |
+
- Accuracy: Correct predictions / Total predictions
|
| 106 |
+
- Precision: True positives / Predicted positives
|
| 107 |
+
- Recall: True positives / Actual positives
|
| 108 |
+
- F1 Score: Harmonic mean of precision and recall
|
| 109 |
+
- AUC-ROC: Area under receiver operating curve
|
| 110 |
+
|
| 111 |
+
### Regression
|
| 112 |
+
- Mean Absolute Error (MAE)
|
| 113 |
+
- Mean Squared Error (MSE)
|
| 114 |
+
- Root Mean Squared Error (RMSE)
|
| 115 |
+
- R-squared (R2)
|
| 116 |
+
|
| 117 |
+
## Getting Started
|
| 118 |
+
|
| 119 |
+
1. Learn Python and libraries (NumPy, Pandas, Scikit-learn)
|
| 120 |
+
2. Work through classic datasets (Iris, MNIST, Titanic)
|
| 121 |
+
3. Take online courses (Coursera, fast.ai)
|
| 122 |
+
4. Practice on Kaggle competitions
|
| 123 |
+
5. Build projects with real-world data
|
| 124 |
+
|
| 125 |
+
Remember: Machine learning is 80% data preparation and 20% modeling. Start with clean data and simple models before going complex.
|