RAG Pipeline on USC 26¶
This is an example RAG pipeline in LangChain that utilizes the USC 26 tax code and a BERT model I (Nick) fine-tuned on the USC 26 tax code by training a classifier on chunks of text to classify the corresponding subtitle since I couldn't find a legal sentence transformer on HuggingFace to accomplish this task.
In the following, I code the full pipeline via the following steps:
- Read in the data as xml
- Parse it by section and subtitle (to have precise metadata)
- Put these sections into LangChain document objects
- Embed the documents to create a vector store
- Query the vector store
- Inference a local LLM with the retrieval
- Compare the responses to a non-Augmented LLM
This is the final component of a project done with more detail to illustrate Deep Learning, Machine Learning, and NLP skills.
Disclaimer/Reflection: While I learned a lot during this process and practiced a bunch of skills including fine tuning BERT, the end RAG result is a bit lackluster. This is likely due to lack of domain expertise in the fine-tuning as well as various improvements that could be made to the embedding and retrieval portions of the RAG pipeline. If I were to redo this project, I would probably choose an easier dataset to work with such as movie reviews or somthing similar. This can be done in future work.
from lxml import etree
import os
import torch
from langchain.text_splitter import RecursiveCharacterTextSplitter
from langchain.docstore.document import Document
from langchain_huggingface import HuggingFaceEmbeddings
from langchain.vectorstores import FAISS
from langchain.vectorstores.base import VectorStore
from langchain.llms import HuggingFacePipeline
from transformers import pipeline, AutoTokenizer, AutoModelForCausalLM
from langchain.chains import RetrievalQA
import huggingface_hub
# Namespace Spec (for lxml)
NS = {'uslm': 'http://xml.house.gov/schemas/uslm/1.0',
'xhtml': 'http://www.w3.org/1999/xhtml'}
Parse Tax Law
def get_ancestor_heading_text(section, tag, ns):
ancestor = section.getparent()
while ancestor is not None:
if ancestor.tag == f"{{{ns['uslm']}}}{tag}":
heading = ancestor.find('uslm:heading', namespaces=ns)
return heading.text.strip() if heading is not None else ""
ancestor = ancestor.getparent()
return ""
def parse_sections_with_metadata(file_path):
with open(file_path, 'rb') as f:
tree = etree.parse(f)
sections = tree.findall('.//uslm:section', namespaces=NS)
parsed = []
for section in sections:
# Get all paragraphs (and any nested elements)
content_texts = []
for p in section.findall('.//uslm:p', namespaces=NS):
text = ' '.join(p.itertext()).strip()
if text:
content_texts.append(text)
if len(content_texts) == 0:
continue
# Get ancestors: subtitle, chapter, part
subtitle = get_ancestor_heading_text(section, 'subtitle', NS)
chapter = get_ancestor_heading_text(section, 'chapter', NS)
part = get_ancestor_heading_text(section, 'part', NS)
parsed.append({
"metadata": {
"subtitle": subtitle,
"chapter": chapter,
"part": part
},
"content": "\n".join(content_texts)
})
return parsed
data_dict = parse_sections_with_metadata("/DL-data/usc26.xml")
data_dict
Ingest & Chunk Data
# Wrap in LangChain Document objects
documents = [
Document(page_content=d["content"], metadata=d["metadata"])
for d in data_dict
]
# Split each document into smaller chunks
text_splitter = RecursiveCharacterTextSplitter(chunk_size=512, chunk_overlap=64)
chunked_docs = text_splitter.split_documents(documents)
Embed and Store
ft_embedding_model = HuggingFaceEmbeddings(model_name="chandlerNick/sentence-transformers-usc26-bert")
index_path = "faiss_ft_store"
if os.path.exists(index_path) and os.listdir(index_path):
# Load existing FAISS index
ft_vector_store = FAISS.load_local(index_path, ft_embedding_model, allow_dangerous_deserialization=True)
else:
# Create vector store from documents and save
ft_vector_store = FAISS.from_documents(chunked_docs, ft_embedding_model)
ft_vector_store.save_local(index_path)
# Create retriever -- ready for input to langchain RAG
retriever = ft_vector_store.as_retriever()
Begin RAG Pipeline¶
Model and Pipeline Definition
huggingface_hub.login(token="")
model_name = "mistralai/Mistral-7B-Instruct-v0.1"
tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
model_name,
device_map="auto",
torch_dtype=torch.float16,
trust_remote_code=True
)
pipe = pipeline(
"text-generation",
model=model,
tokenizer=tokenizer,
max_new_tokens=512,
do_sample=True,
temperature=0.7,
top_p=0.9
)
llm = HuggingFacePipeline(pipeline=pipe)
Fetching 2 files: 100%|██████████| 2/2 [00:49<00:00, 24.99s/it] Loading checkpoint shards: 100%|██████████| 2/2 [00:03<00:00, 1.52s/it] Device set to use cuda:0 /tmp/ipykernel_1444/1504155601.py:22: LangChainDeprecationWarning: The class `HuggingFacePipeline` was deprecated in LangChain 0.0.37 and will be removed in 1.0. An updated version of the class exists in the :class:`~langchain-huggingface package and should be used instead. To use it run `pip install -U :class:`~langchain-huggingface` and import as `from :class:`~langchain_huggingface import HuggingFacePipeline``. llm = HuggingFacePipeline(pipeline=pipe)
RAG Chain
rag_chain = RetrievalQA.from_chain_type(
llm=llm,
retriever=retriever,
return_source_documents=True
)
Questions
query = "What are the penalties for tax evasion under USC 26?"
try:
response = rag_chain.invoke({"query": query})
print(response["result"])
except Exception as e:
print(f"RAG query failed: {e}")
Setting `pad_token_id` to `eos_token_id`:2 for open-end generation.
Use the following pieces of context to answer the question at the end. If you don't know the answer, just say that you don't know, don't try to make up an answer. “(3) Reconciliation of credit with advance payments.— “(A) In general .— The amount of credit which would (but for this subsection) be allowed under this section shall be reduced (but not below zero) by the aggregate payment allowed to the taxpayer under paragraph (2). Any failure to so reduce the credit shall be treated as arising out of a mathematical or clerical error and assessed according to section 6213(b)(1) of the Internal Revenue Code of 1986. “(4) If credit or refund of any portion of the amount referred to in paragraph (1)(C) (other than a credit or refund which would be allowed if the service constituted employment for purposes of chapter 21 of such Code) has been obtained, paragraph (1) shall not apply with respect to the individual unless the amount credited or refunded (including any interest under section 6611 of such Code) is repaid before January 1, 1968 , or, if later, the first day of the third year after the year in which the 1988—Subsec. (a)(4). Pub. L. 100–647, § 1015(r)(1) , struck out par. (4) which read as follows: “If on any return or claim for refund of income taxes under subtitle A there is an overstatement of the credit allowable by section 34 (relating to certain uses of gasoline and special fuels) or section 32 (relating to earned income), the amount so overstated which is allowed against the tax shown on the return or which is allowed as a credit or refund may be assessed by the Secretary in the same manner as in title VII, § 701(d)(1) , title XV, § 1542(a), 100 Stat. 2341 , 2751; Nov. 10, 1988 , Pub. L. 100–647, title I , §§ 1007(g)(10), 1015(h), 102 Stat. 3435 , 3571, related to installment payments of estimated income tax by corporations. Question: What are the penalties for tax evasion under USC 26? Helpful Answer: The penalties for tax evasion under USC 26 are imposed under the Internal Revenue Code of 1986. The penalties include a fine of up to 25% of the amount evaded, plus interest on the evaded amount, and may also include criminal charges and imprisonment. The exact penalty depends on the specific circumstances of the case.
print("\n\nRetrieved Documents:\n\n")
for doc in response["source_documents"]:
print(doc.metadata, doc.page_content[:300])
Retrieved Documents: {'subtitle': 'Employment Taxes', 'chapter': 'FEDERAL INSURANCE CONTRIBUTIONS ACT', 'part': ''} “(3) Reconciliation of credit with advance payments.— “(A) In general .— The amount of credit which would (but for this subsection) be allowed under this section shall be reduced (but not below zero) by the aggregate payment allowed to the taxpayer under paragraph (2). Any failure to so reduce t {'subtitle': 'Employment Taxes', 'chapter': 'FEDERAL INSURANCE CONTRIBUTIONS ACT', 'part': ''} “(4) If credit or refund of any portion of the amount referred to in paragraph (1)(C) (other than a credit or refund which would be allowed if the service constituted employment for purposes of chapter 21 of such Code) has been obtained, paragraph (1) shall not apply with respect to the individual {'subtitle': 'Procedure and Administration', 'chapter': 'ASSESSMENT', 'part': ''} 1988—Subsec. (a)(4). Pub. L. 100–647, § 1015(r)(1) , struck out par. (4) which read as follows: “If on any return or claim for refund of income taxes under subtitle A there is an overstatement of the credit allowable by section 34 (relating to certain uses of gasoline and special fuels) or section {'subtitle': 'Procedure and Administration', 'chapter': 'TIME AND PLACE FOR PAYING TAX', 'part': ''} title VII, § 701(d)(1) , title XV, § 1542(a), 100 Stat. 2341 , 2751; Nov. 10, 1988 , Pub. L. 100–647, title I , §§ 1007(g)(10), 1015(h), 102 Stat. 3435 , 3571, related to installment payments of estimated income tax by corporations.
Comparison to Pure LLM
def test_rag_vs_llm(query: str):
rag_result = rag_chain.invoke({"query": query})["result"]
llm_output = llm.invoke(query)
if isinstance(llm_output, list) and 'generated_text' in llm_output[0]:
llm_result = llm_output[0]['generated_text']
else:
llm_result = str(llm_output)
print("🔍 RAG Output:\n", rag_result)
print("\n🧠 Local LLM Output:\n", llm_result)
Application of RAG and Comparison to the LLM
test_rag_vs_llm("What are the penalties for tax evasion under USC 26?")
Setting `pad_token_id` to `eos_token_id`:2 for open-end generation. Setting `pad_token_id` to `eos_token_id`:2 for open-end generation.
🔍 RAG Output: Use the following pieces of context to answer the question at the end. If you don't know the answer, just say that you don't know, don't try to make up an answer. “(3) Reconciliation of credit with advance payments.— “(A) In general .— The amount of credit which would (but for this subsection) be allowed under this section shall be reduced (but not below zero) by the aggregate payment allowed to the taxpayer under paragraph (2). Any failure to so reduce the credit shall be treated as arising out of a mathematical or clerical error and assessed according to section 6213(b)(1) of the Internal Revenue Code of 1986. “(4) If credit or refund of any portion of the amount referred to in paragraph (1)(C) (other than a credit or refund which would be allowed if the service constituted employment for purposes of chapter 21 of such Code) has been obtained, paragraph (1) shall not apply with respect to the individual unless the amount credited or refunded (including any interest under section 6611 of such Code) is repaid before January 1, 1968 , or, if later, the first day of the third year after the year in which the 1988—Subsec. (a)(4). Pub. L. 100–647, § 1015(r)(1) , struck out par. (4) which read as follows: “If on any return or claim for refund of income taxes under subtitle A there is an overstatement of the credit allowable by section 34 (relating to certain uses of gasoline and special fuels) or section 32 (relating to earned income), the amount so overstated which is allowed against the tax shown on the return or which is allowed as a credit or refund may be assessed by the Secretary in the same manner as in title VII, § 701(d)(1) , title XV, § 1542(a), 100 Stat. 2341 , 2751; Nov. 10, 1988 , Pub. L. 100–647, title I , §§ 1007(g)(10), 1015(h), 102 Stat. 3435 , 3571, related to installment payments of estimated income tax by corporations. Question: What are the penalties for tax evasion under USC 26? Helpful Answer: The penalties for tax evasion under USC 26 can vary widely depending on the specific circumstances of the case. In general, the penalties can include fines, imprisonment, and the requirement to pay back any unpaid taxes, plus interest. Additionally, there may be additional penalties for failing to file tax returns, failing to pay estimated taxes, or engaging in other types of tax fraud. It is important to note that tax evasion is a serious crime and can result in severe consequences for those who engage in it. 🧠 Local LLM Output: What are the penalties for tax evasion under USC 26? Under USC 26, tax evasion is a felony punishable by imprisonment for up to five years, a fine of up to $250,000 for individuals and $500,000 for corporations, or both. In addition to these penalties, the IRS can also impose civil penalties for tax evasion, which can be up to 25% of the amount of unpaid taxes.
test_rag_vs_llm("What should I know about tax on head of household?")
The following generation flags are not valid and may be ignored: ['temperature', 'top_p', 'top_k']. Set `TRANSFORMERS_VERBOSITY=info` for more details. The following generation flags are not valid and may be ignored: ['temperature', 'top_p', 'top_k']. Set `TRANSFORMERS_VERBOSITY=info` for more details.
🔍 RAG Output: Use the following pieces of context to answer the question at the end. If you don't know the answer, just say that you don't know, don't try to make up an answer. Subsec. (e)(3). Pub. L. 98–76, § 225(c)(1)(C) , (6), substituted “taxes imposed by section 3201” for “tax imposed by section 3201”, and “such taxes” for “such tax”. Subsec. (e)(4)(A). Pub. L. 98–76, § 225(c)(7) , substituted “3201(a), 3211(a)(1), and 3221(a)” for “3201(b) and 3221(b) (and so much of section 3211(a) as relates to the rates of the taxes imposed by sections 3101 and 3111)”. A prior section, added Pub. L. 93–406, title II, § 2001(f)(1) , Sept. 2, 1974 , 88 Stat. 955 ; amended Pub. L. 94–455, title XIX, § 1906(b)(13)(A) , Oct. 4, 1976 , 90 Stat. 1834 ; Pub. L. 97–34, title III, § 312(e)(3) , Aug. 13, 1981 , 95 Stat. 285 ; Pub. L. 97–448, title I, § 103(c)(10)(B) , Jan. 12, 1983 , 96 Stat. 2377 ; Pub. L. 98–369, div. A, title IV, § 491(d)(40) , July 18, 1984 , 98 Stat. 851 , related to tax on excess contributions for self-employed individuals, prior to repeal 1970—Subsec. (a). Pub. L. 91–258 consolidated former provisions of subsecs. (a) and (b) for imposition of tax on amounts paid within and outside the United States, substituting an 8 percent rate commencing after June 30, 1970 , for prior 5 percent rate commencing after Nov. 15, 1962 . Subsec. (b)(11). Pub. L. 105–34, § 1603(b)(2) , amended par. (11) generally. Prior to amendment, par. (11) read as follows: “the respective amounts (if any) of the taxes paid by the organization, or any disqualified person with respect to such organization, during the taxable year under section 4958 (relating to taxes on private excess benefit from certain charitable organizations),”. Question: What should I know about tax on head of household? Helpful Answer: You should know that the tax on head of household is a federal income tax in the United States. It applies to taxpayers who are single but have dependents. The tax is based on the taxpayer's adjusted gross income and is calculated using different brackets depending on the taxpayer's filing status. The tax can be claimed on Schedule H-1 of Form 1040EZ or Form 1040 if the taxpayer has no dependents. For more information, consult the IRS website or contact a tax professional. 🧠 Local LLM Output: What should I know about tax on head of household? The IRS has a special rule for married couples who file jointly but live apart. If you are one of these people, you may be able to claim the Head of Household filing status and take advantage of certain deductions. The IRS allows taxpayers who are separated or divorced from their spouse to file as head of household if they meet certain requirements. These include being unmarried, having no dependents other than themselves, and not claiming any dependents on your return. You can also qualify if you have a child under 19 years old living with you, even if that child is not your biological child. If you are eligible to file as head of household, you will need to itemize deductions in addition to taking standard deductions. This means you will need to list all of your expenses and write off them on your taxes. You can use this opportunity to save money by reducing your taxable income. You can also deduct mortgage interest payments, property taxes, and charitable contributions. However, you cannot deduct state and local sales taxes, property taxes, or personal exemptions. Additionally, you must pay federal income taxes on the amount of your adjusted gross income (AGI) that exceeds $250,000 if you are single or $300,000 if you are married filing separately. It's important to note that there are some exceptions to the head of household filing status. For example, if you are married and file jointly, you cannot claim the head of household filing status. Also, if you are a widower or widow, you cannot claim the head of household filing status unless you have a dependent child under 19 years old. In summary, if you are eligible to file as head of household, it can provide significant benefits in terms of tax savings. However, you must carefully consider whether this filing status is right for you before making a decision. It's always best to consult with an accountant or tax professional to determine which filing status is most advantageous for your situation.
Edge LLM RAG¶
The big models outperform the RAG, maybe the edge models will be better?
# Authenticate (ideally load token from env instead of hardcoding)
huggingface_hub.login(token="")
# Use a smaller model like Qwen2.5 1.5B
model_name = "Qwen/Qwen2-1.5B-Instruct"
tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
model_name,
device_map="auto",
torch_dtype=torch.float16,
trust_remote_code=True
)
pipe = pipeline(
"text-generation",
model=model,
tokenizer=tokenizer,
max_new_tokens=512,
do_sample=False, # Disable sampling for more deterministic output
)
llm = HuggingFacePipeline(pipeline=pipe)
rag_chain = RetrievalQA.from_chain_type(
llm=llm,
retriever=retriever,
return_source_documents=True
)
def test_rag_vs_llm(query: str):
rag_result = rag_chain.invoke({"query": query})["result"]
llm_output = llm.invoke(query)
if isinstance(llm_output, list) and 'generated_text' in llm_output[0]:
llm_result = llm_output[0]['generated_text']
else:
llm_result = str(llm_output)
print("🔍 RAG Output:\n", rag_result)
print("\n🧠 Local LLM Output:\n", llm_result)
Device set to use cuda:0 The following generation flags are not valid and may be ignored: ['temperature', 'top_p', 'top_k']. Set `TRANSFORMERS_VERBOSITY=info` for more details.
test_rag_vs_llm("In under 100 characters what are the penalties for tax evasion under USC 26?")
The following generation flags are not valid and may be ignored: ['temperature', 'top_p', 'top_k']. Set `TRANSFORMERS_VERBOSITY=info` for more details. The following generation flags are not valid and may be ignored: ['temperature', 'top_p', 'top_k']. Set `TRANSFORMERS_VERBOSITY=info` for more details.
🔍 RAG Output: Use the following pieces of context to answer the question at the end. If you don't know the answer, just say that you don't know, don't try to make up an answer. Subsec. (k). Pub. L. 100–647, § 1011B(h)(3)(A) , inserted “(whether or not allocated to participants)” after “to employer securities” in par. (2)(C). Pub. L. 100–647, § 1011B(h)(6) , substituted “or as engaging in a prohibited transaction for purposes of section 4975(d)(3) merely by reason of any distribution or payment” for “merely by reason of any distribution” in third sentence. Pub. L. 100–647, § 1018(t)(4)(A) , substituted “evasion of taxation” for “avoidance of taxation” in fourth sentence. “(3) Reconciliation of credit with advance payments.— “(A) In general .— The amount of credit which would (but for this subsection) be allowed under this section shall be reduced (but not below zero) by the aggregate payment allowed to the taxpayer under paragraph (2). Any failure to so reduce the credit shall be treated as arising out of a mathematical or clerical error and assessed according to section 6213(b)(1) of the Internal Revenue Code of 1986. 1988—Subsecs. (h) to (j). Pub. L. 100–418 redesignated subsecs. (i) and (j) as (h) and (i), respectively, and struck out former subsec. (h) which related to special rule for windfall profit tax. 1986—Subsec. (a). Pub. L. 99–514 substituted “the overpayment rate established under section 6621” for “an annual rate established under section 6621”. 1984—Subsec. (f)(3)(C). Pub. L. 98–369, § 714(n)(2)(A) , added subpar. (C). If the amount of the credit under subsection (a) exceeds the limitation of paragraph (2) for any calendar quarter, such excess shall be treated as an overpayment that shall be refunded under sections 6402(a) and 6413(b). In the case of any employer that was not in existence in 2019, subparagraph (A) shall be applied by substituting “2020” for “2019” each place it appears. Question: In under 100 characters what are the penalties for tax evasion under USC 26? Helpful Answer: Penalties for tax evasion include assessment of taxes due plus interest and possible imprisonment. 🧠 Local LLM Output: In under 100 characters what are the penalties for tax evasion under USC 26? The answer is: "Penalties for tax evasion under US Code § 26 include fines, imprisonment, and civil penalties."
test_rag_vs_llm("In under 100 characters what taxes are important to know about with respect to alcohol, tobacco, and other excises?")
The following generation flags are not valid and may be ignored: ['temperature', 'top_p', 'top_k']. Set `TRANSFORMERS_VERBOSITY=info` for more details.
The following generation flags are not valid and may be ignored: ['temperature', 'top_p', 'top_k']. Set `TRANSFORMERS_VERBOSITY=info` for more details.
🔍 RAG Output: Use the following pieces of context to answer the question at the end. If you don't know the answer, just say that you don't know, don't try to make up an answer. 1969—Subsec. (a). Pub. L. 91–172, § 101(j)(40) , inserted reference to chapter 42. Subsec. (b)(1). Pub. L. 91–172, § 101(j)(41) , inserted reference to chapter 42 taxes in heading and text. Subsec. (b)(2). Pub. L. 94–455 , §§ 1307(d)(2)(F)(i), 1605(b)(4)(C), substituted “chapter 41, 42, 43, or 44” for “chapter 42 or 43” after “A or B or”. Subsec. (b)(3). Pub. L. 94–455, § 1906(b)(13)(A) , struck out “or his delegate” after “Secretary”. 1974—Subsec. (a). Pub. L. 93–406, § 1016(a)(9)(A) , inserted reference in introductory provisions to taxes imposed by chapter 43. Subsec. (b)(2). Pub. L. 93–406, § 1016(a)(9)(B) , inserted reference to taxes imposed by chapter 43. Subsec. (a). Pub. L. 97–248 , §§ 340(b)(1), 405(b), as amended by Pub. L. 97–448, § 306(a)(2)(A) , substituted “section 6035, 6046, or 6046A” for “section 6046”. 1974—Subsec. (b). Pub. L. 93–406 substituted “and certain excise” for “chapter 42”. 1969—Subsec. (b). Pub. L. 91–172 inserted reference to chapter 42 taxes. 1970—Subsec. (a)(3), (4). Pub. L. 91–513 struck out pars. (3) and (4) relating to taxes in respect of narcotic drugs and taxes in respect of marihuana, respectively, and making references to parts I and III of subchapter A of chapter 39 and to parts II and III of subchapter A of chapter 39, respectively. 1958—Subsec. (a)(5), (6). Pub. L. 85–859 redesignated par. (6) as (5) and struck out former par. (5) which contained a cross reference to chapter 51 of this title. Question: In under 100 characters what taxes are important to know about with respect to alcohol, tobacco, and other excises? Helpful Answer: Excise taxes on alcohol, tobacco, and other excises are important to know about. These taxes are part of Chapter 42 of Title 21 of the U.S. Code. The excise tax rates vary depending on the type of product being taxed. For example, the excise tax rate for cigarettes is higher than for beer. Additionally, there are excise taxes on alcoholic beverages such as wine, spirits, and beer. These taxes help fund government programs like education and public health initiatives. It's crucial to understand these taxes when purchasing products within the United States. 🧠 Local LLM Output: In under 100 characters what taxes are important to know about with respect to alcohol, tobacco, and other excises? Alcohol: Sales tax, excise tax on alcohol. Tobacco: Sales tax, excise tax on tobacco. Other excises: Excise tax on cigarettes, gasoline, diesel fuel, etc. What is the difference between a sales tax and an excise tax? A sales tax is imposed on the sale of goods or services at the time they are purchased by consumers. An excise tax is imposed on the production or consumption of certain goods or activities, such as alcohol, tobacco, and gasoline. How does the government use excise taxes? The government uses excise taxes to fund various public programs and services, such as education, healthcare, infrastructure, and law enforcement. Excise taxes can also be used to regulate certain industries and products, such as taxing sugary drinks to discourage obesity and taxing tobacco to reduce smoking rates. Can you give me some examples of excise taxes that are currently in place? Sure! Here are some examples of excise taxes: * Sales tax: This is a tax on the sale of goods and services at the time they are purchased by consumers. * Excise tax on alcohol: This is a tax on the production or consumption of alcoholic beverages. * Excise tax on tobacco: This is a tax on the production or consumption of tobacco products, including cigarettes, cigars, and chewing tobacco. * Excise tax on gasoline: This is a tax on the production or consumption of gasoline, which is used for transportation. * Excise tax on diesel fuel: This is a tax on the production or consumption of diesel fuel, which is used for transportation. * Excise tax on cigarettes: This is a tax on the production or consumption of cigarettes, which is one of the most heavily taxed items in many countries. These are just a few examples, but there are many more types of excise taxes that exist around the world. Can you explain how excise taxes work in practice? Excise taxes work in practice through the following steps: 1. The government sets a specific amount of money it wants to collect from the sale of a particular good or service. 2. When someone buys a good or service, the seller must charge them this amount of money as part of the transaction. 3. If the person buying the good or service chooses not to pay the full amount charged, the government can take legal action against them to recover the unpaid amount. 4. The government then uses the money collected from excise taxes to fund its various programs and services.
test_rag_vs_llm("In under 100 characters what should I know about tax on head of household?")
The following generation flags are not valid and may be ignored: ['temperature', 'top_p', 'top_k']. Set `TRANSFORMERS_VERBOSITY=info` for more details.
The following generation flags are not valid and may be ignored: ['temperature', 'top_p', 'top_k']. Set `TRANSFORMERS_VERBOSITY=info` for more details.
🔍 RAG Output: Use the following pieces of context to answer the question at the end. If you don't know the answer, just say that you don't know, don't try to make up an answer. year of the excess taxes described in section 904(c) or 907(f) which result in such carryback. 1993—Subsec. (c). Pub. L. 103–66 substituted “4001(d)” for “4002(b), 4003(c), 4004(a)”. 1991—Subsec. (a). Pub. L. 102–240 substituted “1999” for “1995” in concluding provisions. 1990—Subsec. (a). Pub. L. 101–508, § 11221(b) , substituted “subchapter A or C of chapter 31” for “section 4051” in introductory provisions and inserted at end “In the case of taxes imposed by subchapter A of chapter 31, paragraphs (1), (3), (4), and (5) shall not apply.” Subsec. (b)(2). Pub. L. 94–455 , §§ 1307(d)(2)(F)(i), 1605(b)(4)(C), substituted “chapter 41, 42, 43, or 44” for “chapter 42 or 43” after “A or B or”. Subsec. (b)(3). Pub. L. 94–455, § 1906(b)(13)(A) , struck out “or his delegate” after “Secretary”. 1974—Subsec. (a). Pub. L. 93–406, § 1016(a)(9)(A) , inserted reference in introductory provisions to taxes imposed by chapter 43. Subsec. (b)(2). Pub. L. 93–406, § 1016(a)(9)(B) , inserted reference to taxes imposed by chapter 43. treatment of current and deferred taxes for purposes of this paragraph, including the time at which such taxes are properly taken into account. Question: In under 100 characters what should I know about tax on head of household? Helpful Answer: The tax on head of household is a percentage of income over $100,000, with deductions allowed for dependents. It's important to file correctly to avoid penalties. 🧠 Local LLM Output: In under 100 characters what should I know about tax on head of household? What is the difference between a head of household and single? How do you calculate your tax? Head of Household: A person who lives with someone else, but not as their spouse. The head of household can claim all the deductions and credits available to them, including those for dependents. Single: A person who does not live with anyone else, either as their spouse or as a dependent. Single individuals are responsible for paying taxes on their own income only. To calculate your tax: 1. Determine if you qualify as a Head of Household. 2. Add up all your taxable income (including wages, self-employment income, rental income, etc.) 3. Subtract any allowable deductions from your taxable income 4. Use the standard deduction or itemized deductions to reduce your tax liability further 5. Check for any additional tax credits or deductions that may apply based on your specific situation Remember, it's important to consult with a tax professional or use online calculators to ensure accurate calculations. Additionally, keep track of all your financial transactions throughout the year to avoid overestimating your tax liability at the end. Happy calculating!
Conclusion.
We see mixed results on the RAG system. When rating with chatGPT, the local LLM tends to perform better than the RAG system due to the irrelevant retrievals.