CoolFace
Modelpublic

shiprocket-ai/open-llama-1b-address-completion

sourceHugging Faceapache-2.0updated 1y agoView on Hugging Face
3likes20downloads
Model Card

๐Ÿฆ™ Llama 3.2-1B Address Completion Model

This model is a fine-tuned version of Meta's Llama 3.2-1B-Instruct specialized for address completion and standardization. It's a lightweight, efficient model perfect for address intelligence tasks with reduced computational requirements.

๐ŸŽฏ Model Description

Llama 3.2-1B-Instruct model fine-tuned for address completion and standardization

Key Capabilities

  • โ€”Address Component Extraction: Parse addresses into structured components (building, locality, pincode, etc.)
  • โ€”Address Completion: Complete partial or incomplete addresses
  • โ€”Address Standardization: Convert informal addresses to structured format
  • โ€”Multi-format Support: Handle various address formats and styles
  • โ€”Lightweight Performance: Optimized for speed and efficiency
  • โ€”Contextual Understanding: Leverage relationships between address components

๐Ÿ“Š Model Architecture

  • โ€”Base Model: meta-llama/Llama-3.2-1B-Instruct
  • โ€”Model Type: Causal Language Model (Autoregressive)
  • โ€”Vocabulary Size: 128,256 tokens
  • โ€”Hidden Size: 2048
  • โ€”Number of Layers: 16
  • โ€”Attention Heads: 32
  • โ€”Max Sequence Length: 131072 tokens
  • โ€”Model Size: ~2374MB
  • โ€”Checkpoint: 4390

๐Ÿš€ Usage Examples

python
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM

# Load model and tokenizer
model_name = "shiprocket-ai/open-llama-1b-address-completion"
tokenizer = AutoTokenizer.from_pretrained(model_name)

# Load the merged model (no need for PEFT since weights are already merged)
model = AutoModelForCausalLM.from_pretrained(
    model_name,
    torch_dtype=torch.float16,
    device_map="auto"
)

def extract_address_components(address, max_new_tokens=150):
    """Extract address components using the model"""
    
    # Format prompt for Llama 3.2-1B-Instruct
    prompt = f"""<|begin_of_text|><|start_header_id|>user<|end_header_id|>

Extract address components from: {address}<|eot_id|><|start_header_id|>assistant<|end_header_id|>

"""
    
    # Tokenize
    inputs = tokenizer(prompt, return_tensors="pt", truncation=True, max_length=512)
    
    # FIX: Move inputs to the same device as the model
    device = next(model.parameters()).device
    inputs = {k: v.to(device) for k, v in inputs.items()}
    
    # Generate
    with torch.no_grad():
        outputs = model.generate(
            **inputs,
            max_new_tokens=max_new_tokens,
            temperature=0.1,
            top_p=0.9,
            do_sample=True,
            pad_token_id=tokenizer.eos_token_id,
            repetition_penalty=1.05
        )
    
    # Decode only the new tokens
    input_length = inputs['input_ids'].shape[1]
    generated_tokens = outputs[0][input_length:]
    response = tokenizer.decode(generated_tokens, skip_special_tokens=True)
    
    return response.strip()

# Example usage
test_addresses = [
    "C-704, Gayatri Shivam, Thakur Complex, Kandivali East, 400101",
    "Villa 141, Geown Oasis, V Kallahalli, Off Sarjapur, Bengaluru, Karnataka, 562125",
    "E401 Supertech Icon Indrapam 201301 UP"
]

print("๐Ÿ  ADDRESS EXTRACTION EXAMPLES")
print("=" * 50)

for i, address in enumerate(test_addresses, 1):
    print(f"\n๐Ÿ“ Example {i}: {address}")
    result = extract_address_components(address)
    print(f"๐Ÿค– Extracted: {result}")

๐Ÿ“ˆ Performance Highlights

  • โ€”Lightweight: 1B parameter model for fast inference
  • โ€”Address Intelligence: Specialized for Indian address patterns
  • โ€”Component Extraction: High accuracy in parsing address components
  • โ€”Format Flexibility: Handles various address formats and abbreviations
  • โ€”Speed Optimized: Ultra-fast inference for real-time applications
  • โ€”Memory Efficient: Lower GPU memory requirements
  • โ€”Contextual Awareness: Understands relationships between address components

๐ŸŽญ Supported Address Components

The model can extract and complete the following address components:

  • โ€”Building Names: Apartments, complexes, towers, malls
  • โ€”Localities: Areas, neighborhoods, sectors
  • โ€”Pincodes: 6-digit Indian postal codes
  • โ€”Cities: Major and minor Indian cities
  • โ€”States: All Indian states and union territories
  • โ€”Sub-localities: Sectors, phases, blocks
  • โ€”Road Names: Streets, lanes, main roads
  • โ€”Landmarks: Notable reference points

๐Ÿ”ง Training Details

  • โ€”Dataset: Custom address dataset
  • โ€”Training Strategy: Fine-tuned from pre-trained Llama 3.2-1B-Instruct
  • โ€”Specialization: Address parsing and completion
  • โ€”Context Length: 2048 tokens
  • โ€”Version: 1.0
  • โ€”Framework: PyTorch + Transformers + PEFT

๐Ÿ’ก Use Cases

1. E-commerce & Delivery

  • โ€”Auto-complete customer addresses during checkout
  • โ€”Standardize delivery addresses for logistics
  • โ€”Validate address completeness before shipping

2. Form Auto-filling

  • โ€”Intelligent address suggestions in web forms
  • โ€”Mobile app address completion
  • โ€”Reduce user typing effort

3. Data Cleaning & Migration

  • โ€”Clean legacy address databases
  • โ€”Standardize address formats across systems
  • โ€”Fill missing address components in existing data

4. Edge Deployment

  • โ€”Lightweight model for mobile/edge devices
  • โ€”On-device address processing
  • โ€”Real-time address validation

5. High-throughput Processing

  • โ€”Batch processing of large address datasets
  • โ€”Real-time API endpoints
  • โ€”Cost-effective inference

๐ŸŽฏ Prompt Templates

The model works best with Llama 3.2-1B-Instruct chat format:

Address Extraction

<|begin_of_text|><|start_header_id|>user<|end_header_id|>

Extract address components from: [address_text]<|eot_id|><|start_header_id|>assistant<|end_header_id|>

Address Completion

<|begin_of_text|><|start_header_id|>user<|end_header_id|>

Complete this partial address: [partial_address]<|eot_id|><|start_header_id|>assistant<|end_header_id|>

โšก Performance Tips

  1. 1.Temperature Settings: Use lower temperatures (0.1-0.3) for factual predictions
  2. 2.Context Length: Keep prompts under 512 tokens for optimal performance
  3. 3.Batch Processing: Process multiple addresses in batches for efficiency
  4. 4.GPU Usage: Use half-precision (float16) for faster inference
  5. 5.Format: Use Llama 3.2-1B-Instruct chat format for best results
  6. 6.Edge Deployment: Perfect for mobile and edge deployment scenarios

โš ๏ธ Limitations

  • โ€”Model Size: Smaller model may have reduced capability vs larger models
  • โ€”Training Data: Performance depends on training data coverage
  • โ€”Regional Variations: May work better on certain address formats
  • โ€”Informal Addresses: May struggle with highly colloquial formats
  • โ€”Language: Primarily English; limited regional language support
  • โ€”Context: Works best with complete address context

๐Ÿ“‹ Model Files

  • โ€”config.json: Model configuration and hyperparameters
  • โ€”pytorch_model.bin / model.safetensors: Model weights
  • โ€”tokenizer.json: Tokenizer configuration
  • โ€”tokenizer_config.json: Tokenizer settings
  • โ€”special_tokens_map.json: Special tokens mapping
  • โ€”generation_config.json: Generation parameters

๐Ÿ”„ Model Updates

  • โ€”Version: 1.0 (Checkpoint 4390)
  • โ€”Last Updated: 2025-06-19
  • โ€”Base Model: meta-llama/Llama-3.2-1B-Instruct

๐Ÿ“š Citation

If you use this model in your research or applications, please cite:

bibtex
@misc{llama-1b-address-completion,
  title={Llama 3.2-1B Address Completion Model},
  year={2025},
  publisher={Hugging Face},
  url={https://huggingface.co/shiprocket-ai/open-llama-1b-address-completion}
}

๐Ÿ“ž Support & Contact

For questions, issues, or feature requests:

  • โ€”Open an issue in this repository
  • โ€”Contact: shiprocket-ai team
  • โ€”Documentation: See usage examples above

๐Ÿ“œ License

This model is released under the Llama 2 Community License. See LICENSE file for details.


Lightweight address intelligence - Powered by Llama 3.2-1B-Instruct ๐Ÿฆ™