|
1 | | -# DML-OpenProblem |
| 1 | +# Deep-ML Open Problem Bank |
2 | 2 |
|
3 | | -DML-OpenProblem is an open-source repository of problems focused on linear algebra, machine learning, and deep learning. The problems are designed to be solved from scratch, providing a robust learning experience. This project powers the website [Deep-ML](https://www.deep-ml.com/). |
| 3 | +A community-maintained collection of machine learning coding challenges. |
| 4 | +Each problem lives in its own folder (`questions/<id>_<slug>/`) so contributors can edit Markdown, Python, and JSON files naturally. |
| 5 | +A build script assembles everything into a single JSON file used by [deep-ml.com](https://deep-ml.com). |
4 | 6 |
|
5 | | -## Table of Contents |
| 7 | +--- |
6 | 8 |
|
7 | | -- [Installation](#installation) |
8 | | -- [Usage](#usage) |
9 | | -- [Project Structure](#project-structure) |
10 | | -- [Contributing](#contributing) |
11 | | -- [How to Add an Interactive Learn for a Problem](#how-to-add-an-interactive-learn-for-a-problem) |
12 | | -- [How to Add C++ Questions](#how-to-add-c-questions) |
13 | | -- [License](#license) |
| 9 | +## 📁 Repository Layout |
14 | 10 |
|
15 | | -## Installation |
16 | | - |
17 | | -To get started with DML-OpenProblem, clone the repository and install the necessary dependencies. |
18 | | - |
19 | | -```sh |
20 | | -git clone https://github.com/yourusername/DML-OpenProblem.git |
21 | | -cd DML-OpenProblem |
22 | | -pip install -r requirements.txt |
23 | 11 | ``` |
24 | | -## Usage |
25 | | -You can use the repository to create, edit, and solve problems related to linear algebra, machine learning, and deep learning. The problems are structured in directories, each containing relevant files such as learn.html for the learning section and solution.py for the solution code. |
26 | | - |
27 | | -### Running the Streamlit App |
| 12 | +. |
| 13 | +├─ questions/ |
| 14 | +│ ├─ _template/ ← Copy this to start a new problem |
| 15 | +│ ├─ 101_grpo_objective/ |
| 16 | +│ │ ├─ meta.json |
| 17 | +│ │ ├─ description.md |
| 18 | +│ │ ├─ learn.md |
| 19 | +│ │ ├─ starter_code.py |
| 20 | +│ │ ├─ solution.py |
| 21 | +│ │ ├─ example.json |
| 22 | +│ │ ├─ tests.json |
| 23 | +│ │ ├─ tinygrad/ |
| 24 | +│ │ │ ├─ starter_code.py |
| 25 | +│ │ │ ├─ solution.py |
| 26 | +│ │ │ └─ tests.json |
| 27 | +│ │ └─ pytorch/ |
| 28 | +│ │ ├─ starter_code.py |
| 29 | +│ │ ├─ solution.py |
| 30 | +│ │ └─ tests.json |
| 31 | +│ └─ ... |
| 32 | +│ |
| 33 | +├─ schemas/ |
| 34 | +│ └─ question.schema.json ← JSON-Schema used for validation |
| 35 | +│ |
| 36 | +├─ utils/ |
| 37 | +│ ├─ build_bundle.py ← folder → build/*.json bundler |
| 38 | +│ ├─ validate_questions.py ← schema validator |
| 39 | +│ └─ make_question_template.py← template folder generator |
| 40 | +│ |
| 41 | +└─ .github/workflows/ |
| 42 | + └─ format_questions.yml ← GitHub Action: validate on PR/push |
| 43 | +``` |
28 | 44 |
|
29 | | -To launch the Streamlit application for editing and viewing problems, use the following command: |
| 45 | +--- |
30 | 46 |
|
31 | | -```sh |
32 | | -streamlit run app.py |
33 | | -``` |
| 47 | +## 🛠️ Adding a New Question |
34 | 48 |
|
35 | | -#### Features |
36 | | -- Problem Editor: Edit the learn.html and solution.py files for each problem using a web-based code editor. |
37 | | -- Preview Section: Preview the learning section with LaTeX rendering for mathematical expressions. |
38 | | -- Save Changes: Save your edits to the corresponding files in the repository. |
| 49 | +1. **Copy the template** |
39 | 50 |
|
40 | | -## Project Structure |
41 | | -```sh |
42 | | -DML-OpenProblem/ |
43 | | -│ |
44 | | -├── Problems/ |
45 | | -│ ├── 1_matrix_times_vector/ |
46 | | -│ │ ├── learn.md |
47 | | -│ │ └── solution.py |
48 | | -│ ├── 2_transpose_matrix/ |
49 | | -│ │ ├── learn.md |
50 | | -│ │ └── solution.py |
51 | | -│ └── ... (additional problem directories) |
52 | | -│ |
53 | | -├── app.py |
54 | | -├── requirements.txt |
55 | | -└── README.md |
| 51 | +```bash |
| 52 | +cp -r questions/_template questions/123_my_problem |
56 | 53 | ``` |
57 | | -- **Problems/**: Contains directories for each problem. Each directory includes: |
58 | | - - `learn.md`: markdown file containing the learning section with explanations and examples. |
59 | | - - `solution.py`: Python file containing the solution to the problem along with tests. |
60 | | -- **requirements.txt**: Lists the dependencies required for the project. |
61 | | -- **README.md**: This file. |
62 | | - |
63 | | -## Contributing |
64 | 54 |
|
65 | | -We welcome contributions to improve DML-OpenProblem and [deep-ml.com](https://www.deep-ml.com). If you have a new problem to add or improvements to existing problems, please fork the repository and submit a pull request. All contributions will be displayed on [deep-ml.com](https://www.deep-ml.com). For example, check out this problem: [Divide Dataset Based on Feature Threshold](https://www.deep-ml.com/problem/Divide%20Dataset%20Based%20on%20Feature%20Threshold). A helpfull tool to work on the learn section and know what it would look like on the front end is [https://openproblem-r4vsjwuthdl9a3qzrd4p3m.streamlit.app/](https://dml-openproblem-a5bwuwjh2xeyt5ta5wdiw9.streamlit.app/). Also here is an example of a learn section writing in markdown [Example Problem](https://github.com/Open-Deep-ML/DML-OpenProblem/tree/main/example_problem) |
| 55 | +2. **Fill in the fields** |
66 | 56 |
|
| 57 | +- `meta.json`: question ID, title, category, difficulty, etc. |
| 58 | +- `description.md`: problem statement |
| 59 | +- `learn.md`: explanation and background |
| 60 | +- `starter_code.py`, `solution.py`: reference implementation |
| 61 | +- `example.json`: input/output + reasoning |
| 62 | +- `tests.json`: list of `{ "test": "...", "expected_output": "..." }` |
| 63 | +- Optional language support under `tinygrad/` and `pytorch/` |
67 | 64 |
|
68 | | -### Steps to Contribute |
| 65 | +3. **Run local validation** |
69 | 66 |
|
70 | | -1. Fork the repository. |
71 | | -2. Create a new branch for your feature or bugfix. |
72 | | -3. Make your changes and commit them with clear and concise messages. |
73 | | -4. Push your changes to your fork. |
74 | | -5. Submit a pull request with a detailed description of your changes. |
| 67 | +```bash |
| 68 | +python utils/build_bundle.py && python utils/validate_questions.py |
| 69 | +``` |
75 | 70 |
|
76 | | -### Steps to add a Problem |
77 | | -1. create an issue, the issue should describe the problem you would like to create and use the label "New Problem" |
78 | | -2. comment below the issue you would like to work on |
79 | | -3. We will assign the issue and let you know what number problem to make it |
| 71 | +4. **Open a Pull Request** |
80 | 72 |
|
81 | | -### How to Add a Video Solution (Optional) |
| 73 | +CI will build and validate your changes automatically. |
82 | 74 |
|
83 | | -1. **Create a Comprehensive Video Solution**: |
84 | | - Your video should clearly explain the concept and provide a step-by-step solution to the problem. Feel free to include additional elements that enhance understanding, such as animations, hand-written examples, or any other visual aids that will help clarify the topic. |
| 75 | +--- |
85 | 76 |
|
86 | | -2. **Upload the Video to YouTube**: |
87 | | - Once your video is ready, upload it to YouTube. Make sure the video is accessible and properly titled. |
| 77 | +## 🧪 Schema Validation |
88 | 78 |
|
89 | | -3. **Include a Link to the Problem**: |
90 | | - In the video description, add a link to the corresponding problem on Deep-ML so that viewers can easily access and try solving the problem themselves. |
91 | | - |
92 | | -5. **Submit the Video Link**: |
93 | | -In the corresponding problem folder, create a `.txt` file containing the link to your YouTube video. This will help us easily reference your solution. |
| 79 | +The schema ensures: |
94 | 80 |
|
95 | | -## How to Add an Interactive Learn for a Problem (Optional) |
| 81 | +- Required fields are present |
| 82 | +- Optional `tinygrad_*`, `pytorch_*` are allowed |
| 83 | +- No invalid or extra fields |
96 | 84 |
|
97 | | -1. **Create a Problem Folder**: Navigate to the `Problems/interactive_learn/` directory and create a folder named `problem-N`, where `N` is the problem number assigned to you (e.g., `problem-17`). |
| 85 | +Each question must pass validation before it can be merged. |
98 | 86 |
|
99 | | -2. **Add Learning Materials**: Inside the folder, create a `notebook.py` file. This file should include the learning content with explanations, examples, and any required resources for the problem. You could use https://marimo.app/?slug=aojjhb to ensure the file is compatible with `marimo` for HTML-WASM conversion. For example, you can check [problem-4's notebook.py](Problems/interactive_learn/problem-4/notebook.py) |
| 87 | +--- |
100 | 88 |
|
101 | | -3. **Submit Changes**: Commit the new folder with its contents to your branch and submit a pull request. Ensure your commit messages clearly indicate the addition of the interactive learn for the problem. |
| 89 | +## 🤖 GitHub Actions |
102 | 90 |
|
103 | | -4. **Collaborate for Review**: Engage with reviewers for feedback on your pull request. Make any necessary adjustments as suggested. |
104 | | -## How to Add C++ Questions |
| 91 | +Located in `.github/workflows/format_questions.yml`, this runs: |
105 | 92 |
|
106 | | -We are adding C++ support to the problem set, and you can contribute C++ solutions following these guidelines. |
| 93 | +1. `build_bundle.py` – compiles all question folders |
| 94 | +2. `validate_questions.py` – checks for schema and structure errors |
107 | 95 |
|
108 | | -### Steps to Add a C++ Solution |
| 96 | +CI fails if anything is invalid. |
109 | 97 |
|
110 | | -1. **Select a problem** from the existing Python-based problems. |
111 | | -2. **Create a C++ solution file** inside the corresponding problem folder, naming it `solution.cpp`. |
112 | | -3. **Follow the C++ coding guidelines**: |
113 | | - - Use **C++17 or later**. |
114 | | - - Prefer **Eigen** for matrix operations (or xtensor-blas if necessary). |
115 | | - - Ensure **well-structured, readable, and modular code**. |
116 | | - - Keep solutions **self-contained** and avoid unnecessary external dependencies. |
117 | | - - Format numerical outputs to **4 decimal places** for consistency. |
118 | | -4. **Test your solution** to ensure correctness. |
119 | | -5. **Submit a pull request** with a detailed explanation of your solution. |
| 98 | +--- |
120 | 99 |
|
121 | | -### C++ Coding Rules |
| 100 | +## 📜 License |
122 | 101 |
|
123 | | -- Use **Eigen** for matrix computations where applicable. |
124 | | -- Avoid **excessive STL usage** unless necessary for clarity. |
125 | | -- Prefer **pass-by-reference** over pass-by-value to improve performance. |
126 | | -- Ensure **error handling** without crashing the program. |
127 | | -- Keep solutions **deterministic** and **efficient**. |
| 102 | +All problems are for **educational use only**. |
| 103 | +See `LICENSE` file for full terms. |
128 | 104 |
|
129 | | -If you have any questions about library choices or implementation details, feel free to start a discussion in the GitHub issues section. |
| 105 | +--- |
130 | 106 |
|
131 | | -## License |
| 107 | +## 🙋 Need Help? |
132 | 108 |
|
133 | | -This project is for educational reasons only. See the [LICENSE](LICENSE) file for details. |
| 109 | +Open an issue or visit our Discord: https://discord.gg/JwMePfMZAV |
0 commit comments