VictorOntiveros commited on
Commit
93bf5c2
·
verified ·
1 Parent(s): 10387cd

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +83 -73
README.md CHANGED
@@ -1,123 +1,133 @@
1
  ---
2
- license: mit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  ---
4
 
5
  # Real Estate Assistant – RAG-Based LLM (Victor Ontiveros)
6
 
7
  ## 1. Introduction
8
- The homebuying process is filled with complexity—buyers must consider mortgage eligibility, neighborhood factors, taxes, and investment potential. However, general-purpose large language models (LLMs) often struggle with specificity, hallucinate responses, and fail to capture local nuances. To address these limitations, we developed a Retrieval-Augmented Generation (RAG)-based real estate assistant using the `mistral-7B-instruct` model. This assistant was trained on a validated, synthetic dataset coverin...
9
-
10
- ---
11
 
12
  ## 2. Training Data
13
- We generated a structured synthetic dataset using GPT-4 to simulate realistic user queries. Each example consists of:
14
  - A user query
15
- - A context passage from trusted sources (e.g., Zillow, Freddie Mac, HUD)
16
- - A validated model response
17
 
18
- Data generation followed a few-shot prompting strategy and included rule-based financial checks and real-time API cross-validation. The dataset was split:
19
  - Train: 70%
20
  - Validation: 15%
21
  - Test: 15%
22
  - Random seed: 42
23
 
24
- No pre-existing datasets were used; all examples were generated programmatically and verified using housing, education, and legal APIs.
25
-
26
- ---
27
 
28
  ## 3. Training Method
29
- We fine-tuned `mistral-7B-instruct` using PEFT via LoRA on 4-bit quantized weights (via `bitsandbytes`). This allowed efficient training with reduced hardware requirements.
30
 
31
- **Key settings:**
32
- - Epochs: 3
33
- - Batch size: 8
34
- - Learning rate: 2e-5
35
- - Optimizer: AdamW
36
- - Quantization: 4-bit (nf4)
37
- - Frameworks: Hugging Face Transformers, PEFT
38
 
39
- ---
 
 
 
 
 
40
 
41
- ## 4. Evaluation
42
 
43
- ### Benchmarks Used:
44
- 1. Internal Q&A (ROUGE-1) Measures context comprehension
45
- 2. Mortgage Approval Classification (F1-score)
46
- 3. Zestimate Price Prediction (MAE in USD)
47
-
48
- We compared our model to:
49
- - Base `mistral-7B-instruct`
50
- - FLAN-T5 XL (strong multi-task generalist)
51
- - LLaMA 2 7B (similar size, general domain)
52
 
53
- ### Results Table:
54
 
55
- | Task | Ours (RAG + LoRA) | Mistral-7B | FLAN-T5 XL | LLaMA-2 7B |
56
- |-----------------------------|-------------------|------------|------------|------------|
57
- | Internal QA (ROUGE-1) | 0.68 | 0.44 | 0.51 | 0.49 |
58
- | Mortgage Approval (F1) | 0.84 | 0.62 | 0.68 | 0.71 |
59
- | Zestimate Prediction (MAE) | $21,000 | $48,000 | $39,000 | $34,000 |
 
60
 
61
- **Summary:** Our model shows clear improvements over baseline LLMs, especially in retrieval-grounded Q&A and structured financial tasks.
62
-
63
- ---
64
 
65
  ## 5. Usage and Intended Uses
66
 
67
  ```python
68
- from transformers import AutoTokenizer, AutoModelForCausalLM
69
 
70
- model = AutoModelForCausalLM.from_pretrained("victorontiveros/real-estate-assistant")
71
- tokenizer = AutoTokenizer.from_pretrained("victorontiveros/real-estate-assistant")
72
 
73
- prompt = "User Query: What are the first-time homebuyer programs in Florida?\nContext: Florida offers incentives like..."
74
- inputs = tokenizer(prompt, return_tensors="pt")
75
- output = model.generate(**inputs, max_new_tokens=128)
76
  print(tokenizer.decode(output[0], skip_special_tokens=True))
77
  ```
78
 
79
- Use Cases:
80
- - Estimate monthly mortgage payments
81
- - Identify top-rated school neighborhoods
82
- - Check eligibility for state-specific programs
83
- - Answer zoning or property tax questions
84
-
85
- ---
86
 
87
  ## 6. Prompt Format
88
- Each input follows this format:
89
 
90
  ```
91
- User Query: [natural language question]
92
- Context: [retrieved information relevant to the query]
 
93
  ```
94
 
95
- ---
 
 
 
 
 
 
96
 
97
  ## 7. Expected Output Format
98
- The model returns a concise, well-structured response:
99
 
100
  ```
101
- Based on your savings and income, you qualify for both FHA and conventional loans. Your monthly payment would be ~$1,918 with 20% down.
102
  ```
103
 
104
- ---
105
-
106
  ## 8. Limitations
107
- - The model relies on synthetic data which may underrepresent rare or legal-specific scenarios.
108
- - It doesn’t support real-time data retrieval unless integrated with an external retriever or LangChain.
109
- - There is regional bias toward popular areas like Texas, Florida, and California due to the prompt diversity.
110
- - The assistant may express overconfidence in borderline financial situations without disclaimers.
 
 
 
 
 
 
111
 
112
  ---
113
 
114
- ## References
115
- - [Zillow API](https://www.zillow.com/howto/api/APIOverview.htm)
116
- - [Freddie Mac](https://www.freddiemac.com/research)
117
- - [GreatSchools API](https://www.greatschools.org/gk/about-greatschools-api/)
118
- - [LoRA: Low-Rank Adaptation](https://arxiv.org/abs/2106.09685)
119
- - [Mistral-7B](https://huggingface.co/mistralai/Mistral-7B-Instruct)
120
-
121
- ## Presented by
122
- Victor Ontiveros – UVA SDS Final Project (Spring 2025)
123
 
 
1
  ---
2
+ license: apache-2.0
3
+ base_model: mistralai/Mistral-7B-Instruct
4
+ tags:
5
+ - real-estate
6
+ - RAG
7
+ - retrieval-augmented-generation
8
+ - faiss
9
+ - sentence-transformers
10
+ - financial-qa
11
+ - huggingface
12
+ - synthetic-data
13
+ datasets:
14
+ - custom-synthetic-real-estate-dataset
15
+ metrics:
16
+ - rouge1
17
+ - rougeL
18
+ library_name: transformers
19
+ model_type: mistral
20
+ pipeline_tag: text-generation
21
+ inference: true
22
  ---
23
 
24
  # Real Estate Assistant – RAG-Based LLM (Victor Ontiveros)
25
 
26
  ## 1. Introduction
27
+ The homebuying process is filled with complexity—buyers must consider mortgage eligibility, neighborhood factors, property taxes, and investment potential. However, general-purpose large language models (LLMs) often struggle with specificity, hallucinate responses, and fail to capture local nuances. To address these limitations, I developed a Retrieval-Augmented Generation (RAG)-based real estate assistant using the Mistral-7B model. Instead of traditional fine-tuning, the assistant dynamically retrieves embedded real estate knowledge to generate accurate and grounded responses. The system achieved strong performance across synthetic real estate queries and external evaluation benchmarks including FiQA v2, HotpotQA, and Natural Questions.
 
 
28
 
29
  ## 2. Training Data
30
+ The training data consisted of a structured synthetic real estate dataset designed to simulate realistic user queries. Each example included:
31
  - A user query
32
+ - A real estate context passage
33
+ - A validated reference response
34
 
35
+ The dataset was split as follows:
36
  - Train: 70%
37
  - Validation: 15%
38
  - Test: 15%
39
  - Random seed: 42
40
 
41
+ This synthetic data was specifically generated to cover common real estate financial, legal, and neighborhood-related topics.
 
 
42
 
43
  ## 3. Training Method
44
+ Rather than traditional supervised fine-tuning, I implemented a custom Retrieval-Augmented Generation (RAG) pipeline:
45
 
46
+ - Context embeddings were generated using a sentence-transformer model (`all-MiniLM-L6-v2`).
47
+ - FAISS indexing enabled efficient retrieval of similar contexts.
48
+ - The retrieved contexts were fed into the Mistral-7B model for response generation.
 
 
 
 
49
 
50
+ **Hyperparameters and retrieval settings:**
51
+ - Top-k retrieved contexts: 3
52
+ - Max new tokens during generation: 300
53
+ - Temperature: 0.7
54
+ - Device: CUDA (float16 precision)
55
+ - Frameworks used: Hugging Face Transformers, Sentence-Transformers, FAISS
56
 
57
+ This setup allows dynamic, context-grounded generation without traditional parameter updates to the base model.
58
 
59
+ ## 4. Evaluation
60
+ Performance was benchmarked across both synthetic real estate queries and external benchmarks.
 
 
 
 
 
 
 
61
 
62
+ ### Evaluation Results
63
 
64
+ | Dataset | ROUGE-1 F1 | ROUGE-L F1 |
65
+ |:-------------------------|:-----------|:-----------|
66
+ | Synthetic (Internal) | ~0.10 | ~0.07 |
67
+ | FiQA v2 (Financial QA) | ~0.33 | ~0.30 |
68
+ | HotpotQA (Multi-hop QA) | ~0.11 | ~0.10 |
69
+ | Natural Questions (Open QA) | ~0.02 | ~0.01 |
70
 
71
+ The model achieved strong domain-specific performance on FiQA v2 and synthetic data. It showed moderate generalization on HotpotQA and struggled on open-ended Natural Questions, confirming the importance of domain-specific retrieval for real estate tasks.
 
 
72
 
73
  ## 5. Usage and Intended Uses
74
 
75
  ```python
76
+ from transformers import AutoModelForCausalLM, AutoTokenizer
77
 
78
+ model = AutoModelForCausalLM.from_pretrained("your-username/your-real-estate-assistant")
79
+ tokenizer = AutoTokenizer.from_pretrained("your-username/your-real-estate-assistant")
80
 
81
+ query = "I have $90K budget. What are my first-time homebuyer options in Austin, TX?"
82
+ inputs = tokenizer(query, return_tensors="pt")
83
+ output = model.generate(**inputs, max_new_tokens=300)
84
  print(tokenizer.decode(output[0], skip_special_tokens=True))
85
  ```
86
 
87
+ **Intended Uses:**
88
+ - Homebuyer education and affordability guidance
89
+ - Mortgage eligibility exploration
90
+ - Real estate investment decision support
91
+ - School rating and relocation assistance
 
 
92
 
93
  ## 6. Prompt Format
94
+ Each input consists of a user query combined with retrieved context:
95
 
96
  ```
97
+ User Query: [user's question]
98
+ Context: [retrieved background information]
99
+ Answer:
100
  ```
101
 
102
+ Example:
103
+
104
+ ```
105
+ User Query: What are the average property taxes in Travis County, TX?
106
+ Context: The average property tax rate in Travis County, Texas is 2.1% as of 2024, based on Zillow estimates and tax assessor data.
107
+ Answer:
108
+ ```
109
 
110
  ## 7. Expected Output Format
111
+ The model returns fluent, grounded natural language responses:
112
 
113
  ```
114
+ In Travis County, property tax rates typically average 2.1% of assessed home value, although actual rates may vary based on exemptions and city-specific factors.
115
  ```
116
 
 
 
117
  ## 8. Limitations
118
+ - The model relies heavily on the quality and relevance of retrieved contexts; weak retrieval can degrade output quality.
119
+ - Performance on open-domain general queries (as seen with Natural Questions) remains limited.
120
+ - Since the model is based on synthetic training data, it may not perfectly generalize to all real-world scenarios.
121
+ - Generated responses do not constitute legal, tax, or financial advice and should be validated by experts.
122
+
123
+ ## References
124
+ - [FAISS - Facebook AI Similarity Search](https://github.com/facebookresearch/faiss)
125
+ - [Hugging Face Transformers](https://huggingface.co/docs/transformers/index)
126
+ - [Sentence Transformers](https://www.sbert.net/)
127
+ - [Mistral-7B Model Card](https://huggingface.co/mistralai/Mistral-7B-Instruct)
128
 
129
  ---
130
 
131
+ Presented by Victor Ontiveros – UVA SDS Final Project (Spring 2025)
132
+
 
 
 
 
 
 
 
133