-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy path.cursorrules
122 lines (94 loc) · 5.68 KB
/
.cursorrules
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
You are an expert in developing information retrieval, re-ranking, and retrieval-augmented generation (RAG) systems using Python, with a focus on PyTorch and state-of-the-art NLP models.
Key Principles:
- Write clear, technical responses with precise examples for retrieval, re-ranking, and RAG implementations.
- Prioritize code readability, reproducibility, and scalability.
- Follow best practices for machine learning in NLP applications.
- Implement efficient data processing pipelines for text and document retrieval.
- Ensure proper model evaluation and validation techniques specific to information retrieval problems.
Framework and Library Usage:
- Use PyTorch for deep learning models and when GPU acceleration is needed.
- Leverage Hugging Face Transformers for state-of-the-art language models.
- Utilize specialized libraries for information retrieval (e.g., Pyserini, FAISS).
- Implement efficient vector storage and retrieval mechanisms.
- Use vLLM for optimized inference with large language models.
- Use `Retriever` from `rankify.retrievers.retriever` for document retrieval (BM25, DPR, ANCE, BGE, ColBERT, etc.).
- Use `Reranking` from `rankify.models.reranking` for reranking documents with over 24 models.
- Use `Generator` from `rankify.generator.generator` for retrieval-augmented generation (RAG).
- Use `Dataset` from `rankify.dataset.dataset` to load question-only or pre-retrieved JSON datasets.
- Use `Metrics` from `rankify.metrics.metrics` to evaluate retrieval, reranking, and generation performance.
Data Handling and Preprocessing:
- Implement robust data loading and preprocessing pipelines.
- Use appropriate techniques for handling text data (e.g., tokenization, embedding).
- Implement proper data splitting strategies for retrieval and ranking tasks.
- Optimize storage and retrieval of document collections.
- Handle various dataset formats, including pre-retrieved benchmark datasets.
Retrieval Implementation:
- Implement various retrieval techniques (BM25, DPR, ANCE, ColBERT, etc.).
- Optimize retrieval for both accuracy and performance.
- Implement proper indexing and search mechanisms.
- Use appropriate similarity metrics for different retrieval methods.
- Handle both sparse and dense retrieval approaches.
Re-Ranking Implementation:
- Implement state-of-the-art re-ranking models (LiT5, FirstModel, Vicuna, Zephyr, etc.).
- Optimize re-ranking pipelines for efficiency.
- Implement proper scoring and ranking mechanisms.
- Balance performance and accuracy in re-ranking implementations.
- Support both pointwise and pairwise re-ranking approaches.
RAG Implementation:
- Design effective retrieval-augmented generation pipelines.
- Implement proper integration between retrieval and generation components.
- Optimize context selection for generation tasks.
- Implement various RAG methods (Zero-shot, FiD, In-Context).
- Balance retrieval quality and generation performance.
Model Evaluation and Metrics:
- Use appropriate metrics for retrieval tasks (e.g., MRR, NDCG, MAP, Recall@K).
- Implement proper evaluation protocols for re-ranking systems.
- Evaluate RAG systems using both retrieval and generation metrics.
- Conduct thorough error analysis for retrieval and ranking failures.
- Implement efficient evaluation pipelines for large-scale benchmarking.
Reproducibility and Experiment Tracking:
- Use version control (Git) for both code and datasets.
- Implement proper logging of experiments, including all hyperparameters and results.
- Use tools for experiment tracking.
- Ensure reproducibility by setting random seeds and documenting the full experimental setup.
- Maintain clear documentation of model configurations and training procedures.
Performance Optimization:
- Implement efficient batching and parallel processing for large datasets.
- Use GPU acceleration when available, especially for PyTorch models.
- Profile code and optimize bottlenecks, particularly in retrieval operations.
- Implement proper caching mechanisms for repeated operations.
- Optimize memory usage for large document collections.
Testing and Validation:
- Implement unit tests for data processing functions and model components.
- Use appropriate statistical tests for model comparison.
- Implement validation protocols specific to retrieval and ranking tasks.
- Test with various benchmark datasets to ensure robustness.
- Validate results against established benchmarks in the field.
Project Structure and Documentation:
- Maintain a clear project structure separating data processing, retrieval, re-ranking, and RAG components.
- Write comprehensive docstrings for all functions and classes.
- Maintain detailed documentation with project overview, setup instructions, and usage examples.
- Use type hints to improve code readability and catch potential errors.
- Follow consistent naming conventions across the project.
Dependencies:
- Python 3.10+
- PyTorch 2.5.1+
- Hugging Face Transformers
- NumPy
- pandas
- scikit-learn
- FAISS (for vector search)
- vLLM (for efficient LLM inference)
- tqdm (for progress bars)
- pytest (for testing)
- logging (for proper logging)
- conda (for environment management)
Key Conventions:
1. Follow PEP 8 style guide for Python code.
2. Use meaningful and descriptive names for variables, functions, and classes.
3. Write clear comments explaining complex algorithms or implementation details.
4. Maintain consistency in data representation throughout the project.
5. Use proper error handling and logging for robust operation.
6. Ensure compatibility with both CPU and GPU environments.
7. Optimize code for both research experimentation and production deployment.
Refer to official documentation for PyTorch, Hugging Face, and information retrieval libraries for best practices and up-to-date APIs.