CoolFace
Apppublic

Shivaaaahdjdnd/code_analysis

sourceHugging Faceupdated 3mo agoView on Hugging Face
0likes
README.md158 linesDownload Raw Back to root
1---2title: Qwen2.5 Coding Analyzer3emoji: ๐Ÿš€4colorFrom: blue5colorTo: purple6sdk: docker7app_file: app.py8pinned: false9---10 11# ๐Ÿš€ Qwen2.5-1.5B Coding Analysis System12 13AI-powered coding solution analyzer using Qwen2.5-1.5B-Instruct with HackerRank-level evaluation metrics.14 15## ๐ŸŒŸ Features16 17### ๐ŸŽฏ AI-Powered Analysis18- **Correctness** (40 points): Syntax validation + real test execution + AI logic review19- **Code Quality** (25 points): Readability + structure + naming + comments + best practices20- **Efficiency** (20 points): Time/space complexity + optimization suggestions21- **AI Detection** (-10 penalty): Detects AI-generated code patterns22- **Similarity Check** (-5 penalty): Plagiarism detection vs reference solution23 24### ๐Ÿค– Qwen2.5-1.5B Integration25- **1.5B parameters** optimized for code analysis on CPU26- **Multi-language support**: Python, Java, C++, JavaScript27- **Real test execution** for Python submissions28- **Context-aware recommendations**29 30## ๐Ÿš€ API Usage31 32### Endpoint33```34POST /api/batch-analysis35```36 37### Request Body38```json39{40  "submissions": [41    {42      "question": "Find two numbers that add up to target",43      "user_code": "def two_sum(nums, target):\n    for i in range(len(nums)):\n        for j in range(i+1, len(nums)):\n            if nums[i] + nums[j] == target:\n                return [i, j]\n    return []",44      "correct_solution": "def two_sum(nums, target):\n    seen = {}\n    for i, num in enumerate(nums):\n        if target - num in seen:\n            return [seen[target - num], i]\n        seen[num] = i\n    return []",45      "language": "python",46      "difficulty": "easy",47      "test_cases": [48        {"input": [[2, 7, 11, 15], 9], "expected_output": "[0, 1]"}49      ]50    }51  ]52}53```54 55### Optional Fields (per submission)56| Field | Default | Options |57|---|---|---|58| `language` | `"python"` | `python`, `java`, `cpp`, `javascript` |59| `difficulty` | `"medium"` | `easy`, `medium`, `hard` |60| `test_cases` | `null` | Array of `{input, expected_output}` |61 62### Response Body63```json64{65  "status": "completed",66  "total_submissions": 1,67  "average_score": 66.0,68  "results": [69    {70      "submission_id": 1,71      "question_title": "Find two numbers that add up to target",72      "overall_score": 66,73      "max_score": 100,74      "status": "completed",75      "analysis": {76        "correctness": {"score": 40, "syntax_valid": true, "logic_correct": true, "test_cases_passed": 1, "total_test_cases": 1},77        "code_quality": {"score": 16, "readability": 4, "structure": 4, "naming": 3, "comments": 0, "best_practices": 5},78        "efficiency": {"score": 10, "time_complexity": "O(nยฒ)", "space_complexity": "O(1)"},79        "ai_detection": {"penalty": 0, "ai_probability": 5},80        "similarity": {"penalty": 0, "similarity_ratio": 0.45}81      },82      "feedback": "Solution is correct but uses O(nยฒ) time complexity. Consider using a hash map for O(n) solution.",83      "recommendations": ["Use a dictionary to store seen values for O(n) time complexity"]84    }85  ]86}87```88 89### Health Check90```91GET /health92```93Returns model load status and AI enabled flag.94 95## ๐Ÿ› ๏ธ Quick Setup96 97### Local Development98```bash99pip install -r requirements.txt100python app.py101```102 103### Docker104```bash105docker build -t qwen-analyzer .106docker run -p 7860:7860 qwen-analyzer107```108 109### Test the API110```bash111python test_live_api.py112python test_batch.py113```114 115## ๐Ÿ“Š Scoring System116 117| Component | Points | Description |118|---|---|---|119| **Correctness** | 40 | Syntax + Real Test Execution + AI Logic Review |120| **Quality** | 25 | Readability + Structure + Naming + Comments |121| **Efficiency** | 20 | Time/Space Complexity |122| **AI Penalty** | -10 | AI-generated code detection |123| **Similarity** | -5 | Plagiarism detection |124 125### Time Complexity Scoring126| Complexity | Points |127|---|---|128| O(1) | 20 |129| O(log n) | 18 |130| O(n) | 15 |131| O(n log n) | 12 |132| O(nยฒ) | 8 |133| O(nยณ) | 4 |134 135## ๐Ÿ”ง Configuration136 137Environment variables:138```bash139MODEL_NAME=Qwen/Qwen2.5-1.5B-Instruct140PORT=7860141TEMPERATURE=0.1142MAX_NEW_TOKENS=600143```144 145## ๐Ÿšจ System Requirements146 147- **Python**: 3.10+148- **RAM**: 4GB minimum (8GB recommended)149- **Storage**: 4GB for model cache150- **GPU**: Optional (CUDA-compatible for faster inference)151 152## ๐Ÿ“„ License153 154MIT License155 156---157 158**Powered by Qwen2.5-1.5B-Instruct** ๐Ÿค–