🎯 Mistral-7B AI Project Scoper & Metadata Extractor (LoRA)

Transform vague AI ideas into structured, actionable project specifications β€” automatically.

A lightweight LoRA adapter for Mistral-7B that converts natural language project requests into:

  1. Clarifying questions to refine scope
  2. Structured JSON metadata for downstream ML pipelines

Perfect for product managers, ML engineers, consultants, and AI platforms that need to standardize project intake.


✨ Key Features

Feature Benefit
πŸ” Smart Questioning Asks targeted follow-ups to eliminate ambiguity
🧩 Structured Output Returns parseable JSON with task type, domain, modality & classes
⚑ Lightweight ~100MB adapter (vs 14GB full model) β€” fast to download & deploy
πŸ” Plug-and-Play Works with any Mistral-7B base model via PEFT
🌐 Domain-Agnostic Trained on finance, e-commerce, healthcare, real estate & more

πŸ“¦ Installation

# Required packages
pip install transformers peft accelerate torch

# Optional: for JSON parsing & evaluation
pip install jsonschema scikit-learn

πŸš€ Quick Start

Basic Inference (GPU)

from transformers import AutoTokenizer, AutoModelForCausalLM
from peft import PeftModel
import re, json, torch

# Configuration
BASE_MODEL = "mistralai/Mistral-7B-v0.1"
ADAPTER_ID = "sarimahsan101/mistral-7b-ai-project-scoper-lora"  

# Load model & tokenizer
tokenizer = AutoTokenizer.from_pretrained(ADAPTER_ID)
base_model = AutoModelForCausalLM.from_pretrained(
    BASE_MODEL,
    device_map="auto",
    torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32,
    low_cpu_mem_usage=True
)
model = PeftModel.from_pretrained(base_model, ADAPTER_ID)
model.eval()

def scope_project(user_input: str) -> dict:
    """Convert natural language request β†’ structured metadata"""
    prompt = f"""### Instruction:
{user_input}

### Input:

### Response:
"""
    inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
    
    with torch.no_grad():
        outputs = model.generate(
            **inputs,
            max_new_tokens=300,
            do_sample=False,          # Deterministic for reliability
            temperature=0.0,
            pad_token_id=tokenizer.pad_token_id,
            eos_token_id=tokenizer.eos_token_id
        )
    
    response = tokenizer.decode(outputs[0], skip_special_tokens=True)
    
    # Extract JSON block
    json_match = re.search(r"\{[\s\S]*\}", response)
    if json_match:
        try:
            return json.loads(json_match.group())
        except json.JSONDecodeError:
            return {"error": "Failed to parse JSON", "raw_response": response}
    return {"error": "No JSON found in response"}

# Example usage
result = scope_project("I want to detect fake reviews on my e-commerce site")
print(json.dumps(result, indent=2))

CPU-Only Fallback

# Just change device_map and dtype:
base_model = AutoModelForCausalLM.from_pretrained(
    BASE_MODEL,
    device_map="cpu",
    torch_dtype=torch.float32
)

πŸ“š Training Data Overview

This adapter was fine-tuned on ~2,500 curated instruction-response pairs following the Alpaca format:

{
  "instruction": "User's project idea or request",
  "input": "",
  "output": "Questions:\n1. ...\n2. ...\n\nJSON:\n{...}"
}

Domain Distribution

Domain % of Data Example Tasks
🏦 Finance 25% Fraud detection, stock prediction, credit scoring
πŸ›’ E-Commerce 20% Sentiment analysis, recommendation, review classification
πŸ₯ Healthcare 15% Diagnosis support, patient triage, medical NER
🏠 Real Estate 12% Price prediction, property classification, lead scoring
πŸ€– General AI/ML 28% Chatbots, automation, data pipelines, model selection

Output Schema

Every response contains:

{
  "task": "string",           // e.g., "binary_classification", "regression", "text_generation"
  "domain": "string",         // e.g., "finance", "healthcare", "unknown"
  "modality": "string",       // "text", "tabular", "image", "audio", "multimodal"
  "dataset_provided": boolean,
  "classes": ["string"] | null
}

πŸ’¬ Sample Inputs & Outputs

Example 1: Finance Project

Input:

I want to build an AI that predicts which customers will churn next month

Output:

Questions:
1. Do you have historical customer behavior data (logins, purchases, support tickets)?
2. What defines "churn" in your business? (cancellation, inactivity, downgrade?)
3. Is this for B2C or B2B customers?

JSON:
{
  "task": "binary_classification",
  "domain": "saas",
  "modality": "tabular",
  "dataset_provided": false,
  "classes": ["churn", "retain"]
}

Example 2: NLP Project

Input:

Create a chatbot that answers questions about our company's HR policies

Output:

Questions:
1. Do you have documented HR policies in text/PDF format?
2. Should the bot handle multi-turn conversations or single Q&A?
3. What languages need to be supported?

JSON:
{
  "task": "retrieval_augmented_generation",
  "domain": "human_resources",
  "modality": "text",
  "dataset_provided": false,
  "classes": null
}

Example 3: Ambiguous Request

Input:

Make something cool with AI

Output:

Questions:
1. What problem or task would you like AI to help with?
2. What type of data do you have access to? (text, images, numbers, audio)
3. Who is the end user and how will they interact with it?

JSON:
{
  "task": "unknown",
  "domain": "unknown", 
  "modality": "unknown",
  "dataset_provided": false,
  "classes": "unknown"
}

πŸ”§ Advanced Usage

Batch Processing

from tqdm import tqdm

def batch_scope_requests(requests: list[str]) -> list[dict]:
    results = []
    for req in tqdm(requests):
        results.append(scope_project(req))
    return results

# Example
requests = [
    "Predict house prices from CSV",
    "Classify support tickets by urgency",
    "Generate marketing copy for products"
]
outputs = batch_scope_requests(requests)

JSON Schema Validation

from jsonschema import validate, ValidationError

SCHEMA = {
    "type": "object",
    "properties": {
        "task": {"type": "string"},
        "domain": {"type": "string"},
        "modality": {"type": "string", "enum": ["text", "tabular", "image", "audio", "multimodal", "unknown"]},
        "dataset_provided": {"type": "boolean"},
        "classes": {"type": ["array", "null"]}
    },
    "required": ["task", "domain", "modality", "dataset_provided"]
}

def validate_output(metadata: dict) -> bool:
    try:
        validate(instance=metadata, schema=SCHEMA)
        return True
    except ValidationError as e:
        print(f"Validation error: {e.message}")
        return False

Integration with LangChain

from langchain_core.prompts import PromptTemplate
from langchain_core.output_parsers import JsonOutputParser

# Use as a LangChain tool
def create_scoping_tool():
    return {
        "name": "scope_ai_project",
        "description": "Converts vague AI project ideas into structured metadata",
        "function": scope_project
    }

πŸ§ͺ Evaluation & Testing

Quick Accuracy Check

# Test on held-out examples
test_cases = [
    ("Detect spam emails", "binary_classification", "text"),
    ("Forecast sales from CSV", "regression", "tabular"),
    ("Summarize news articles", "text_summarization", "text")
]

correct = 0
for prompt, expected_task, expected_modality in test_cases:
    result = scope_project(prompt)
    if result.get("task") == expected_task and result.get("modality") == expected_modality:
        correct += 1

print(f"Accuracy: {correct}/{len(test_cases)} ({100*correct/len(test_cases):.1f}%)")

Recommended Metrics

Metric Target Why
JSON Parse Rate >95% Ensures reliable downstream integration
Task Classification Accuracy >85% Core capability for routing projects
Question Relevance (human eval) >4/5 Quality of scoping guidance
Latency (A10G) <3s/request Production readiness

⚠️ Limitations & Best Practices

Known Limitations

  • ❌ Not trained for code generation or deployment scripts
  • ❌ May hallucinate classes if prompt is extremely vague
  • ❌ JSON extraction requires post-processing (regex/parser)
  • ❌ Performance degrades on non-English inputs

Best Practices

βœ… Always validate JSON output before using in pipelines
βœ… Use deterministic decoding (do_sample=False) for production
βœ… Cache base model locally to avoid repeated downloads
βœ… Combine with human review for high-stakes project scoping
βœ… Log failed parses to iteratively improve prompt engineering


🀝 Contributing

Found a bug or want to add support for a new domain?

  1. Fork the repo
  2. Create a feature branch: git checkout -b feat/add-healthcare-tasks
  3. Add test cases in tests/samples.jsonl
  4. Submit a PR with:
    • Description of the new task/domain
    • 3-5 example input/output pairs
    • Updated evaluation metrics (if applicable)

We especially welcome contributions for:

  • 🌍 Non-English language support
  • 🏭 Industry-specific schemas (manufacturing, logistics, education)
  • πŸ”’ PII-aware scoping for regulated domains

πŸ“œ License & Attribution

  • Adapter License: Apache 2.0
  • Base Model: Mistral-7B-v0.1 (Apache 2.0)
  • Training Framework: PEFT + Transformers (Hugging Face)

If you use this adapter in research or production, please cite:

@software{mistral_ai_project_scoper_lora,
  title = {Mistral-7B AI Project Scoper LoRA Adapter},
  author = {Sarim Ahsan},
  year = {2026},
  url = {https://huggingface.co/sarimahsan101/mistral-7b-ai-project-scoper-lora}
}

πŸ’¬ Support & Community

  • πŸ’‘ Feature Requests: Discussions Tab
  • πŸ”„ Model Updates: Follow the repo for new adapter versions
  • 🌟 Showcase: Tag #AIPrjectScoper when you build something cool!

Made with ❀️ for the open-source AI community


πŸ“€ Final Push Command

from huggingface_hub import login, create_repo

login()  # Enter your HF token

repo_id = "sarimahsan101/mistral-7b-ai-project-scoper-lora"

# Optional: create repo explicitly if not auto-created
create_repo(repo_id, exist_ok=True, private=False)

# Push adapter + tokenizer + README
model.push_to_hub(repo_id)
tokenizer.push_to_hub(repo_id)

print(f"βœ… Live at: https://huggingface.co/{repo_id}")

πŸ” SEO Boosters Included

  • Frontmatter tags match common HF search queries (metadata-extraction, structured-output)
  • library_name: peft enables framework-based discovery
  • Code blocks use syntax highlighting for better readability
  • Schema + validation section attracts enterprise users
  • Sample I/O pairs improve click-through from search results
Downloads last month
8
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Model tree for sarimahsan101/mistral-7b-ai-project-scoper-lora

Adapter
(2461)
this model