CoolFace
Modelpublic

sarimahsan101/mistral-7b-ai-project-scoper-lora

sourceHugging Faceapache-2.0updated 5mo agoView on Hugging Face
0likes10downloads
Model Card

๐ŸŽฏ 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. 1.Clarifying questions to refine scope
  2. 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

FeatureBenefit
๐Ÿ” Smart QuestioningAsks targeted follow-ups to eliminate ambiguity
๐Ÿงฉ Structured OutputReturns parseable JSON with task type, domain, modality & classes
โšก Lightweight~100MB adapter (vs 14GB full model) โ€” fast to download & deploy
๐Ÿ” Plug-and-PlayWorks with any Mistral-7B base model via PEFT
๐ŸŒ Domain-AgnosticTrained on finance, e-commerce, healthcare, real estate & more

๐Ÿ“ฆ Installation

bash
# Required packages
pip install transformers peft accelerate torch

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

๐Ÿš€ Quick Start

Basic Inference (GPU)

python
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

python
# 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:

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

Domain Distribution

Domain% of DataExample Tasks
๐Ÿฆ Finance25%Fraud detection, stock prediction, credit scoring
๐Ÿ›’ E-Commerce20%Sentiment analysis, recommendation, review classification
๐Ÿฅ Healthcare15%Diagnosis support, patient triage, medical NER
๐Ÿ  Real Estate12%Price prediction, property classification, lead scoring
๐Ÿค– General AI/ML28%Chatbots, automation, data pipelines, model selection

Output Schema

Every response contains:

json
{
  "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

python
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

python
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

python
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

python
# 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

MetricTargetWhy
JSON Parse Rate>95%Ensures reliable downstream integration
Task Classification Accuracy>85%Core capability for routing projects
Question Relevance (human eval)>4/5Quality of scoping guidance
Latency (A10G)<3s/requestProduction 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. 1.Fork the repo
  2. 2.Create a feature branch: git checkout -b feat/add-healthcare-tasks
  3. 3.Add test cases in tests/samples.jsonl
  4. 4.Submit a PR with:
  5. 5.Description of the new task/domain
  6. 6.3-5 example input/output pairs
  7. 7.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:

bibtex
@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

python
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