Skip to content

Commit

Permalink
Added pipelines (#17)
Browse files Browse the repository at this point in the history
Batch processing and process images

headless opencv

Raise caught errors and get filename from image path

Connect process image with detect objects

Begin splitting the pipelines

Claim id bug

Updated pipelines and requirements

Processing pipeline working with object detection
  • Loading branch information
RHRolun authored Dec 13, 2023
1 parent 7cbe35d commit 420ca71
Show file tree
Hide file tree
Showing 29 changed files with 1,528 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lab-materials/03/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM quay.io/modh/runtime-images@sha256:8b962c575adfdb46a9aa3e3fc30fdbe470d049b0ff69f68c5c9f950496ae26c5

COPY requirements.txt ./
RUN pip install -r requirements.txt
3 changes: 3 additions & 0 deletions lab-materials/03/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# 04

Instructions for how to run the sanity pipeline...
Empty file removed lab-materials/03/empty.txt
Empty file.
43 changes: 43 additions & 0 deletions lab-materials/03/example_text.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
Subject: Claim for Recent Car Accident - Policy Number: ABC12345

Dear XYZ Insurance Company,

I hope this email finds you well. I am writing to report a recent car accident in which I was involved, and I would like to initiate a claim under my policy with your company. My policy number is ABC12345, and my name is John Smith.

Accident Details:

Date and Time: The accident occurred on October 15, 2023, at approximately 2:30 PM.

Location: The accident took place at the intersection of Elm Street and Maple Avenue, near Smith Park, in Springfield, Illinois. The exact coordinates are 39.7476° N, 89.6960° W.

Circumstances:

1. Weather Conditions: On the day of the accident, the weather was overcast with light rain. The road was wet.

2. Traffic Conditions: Traffic was moderate at the time, with vehicles traveling in all directions. I was driving at the posted speed limit of 35 mph.

3. Vehicle Involved: I was driving my Honda Accord at the time of the accident. The other party involved was driving a Ford Escape.

4. Sequence of Events: While I was proceeding through the intersection with a green light, the other vehicle, which was coming from the north, ran a red light and collided with the front passenger side of my vehicle. I had no time to react to avoid the collision.

5. Injuries: Thankfully, there were no serious injuries, but both vehicles sustained significant damage. The police were called to the scene, and a report was filed. The officer's badge number is 12345, and I can provide a copy of the accident report upon request.

6. Witness Information: There were a few witnesses to the accident, and I have their contact information. Their names are Sarah Johnson, Mark Williams, and Lisa Anderson.

7. Photos: I have taken several photos of the accident scene, including the damage to both vehicles, the traffic signals, and road conditions. I can provide these photos to assist with the claim.

8. Other Party's Information: The driver of the other vehicle provided me with their insurance information and contact details, which I can share with you.

Claim Request:

I would like to request that you initiate a claim under my policy for the damages to my vehicle. I would appreciate it if you could provide me with the next steps and the claim process. Please let me know what documentation or information you require from me to process this claim efficiently.

I understand that accidents happen, and I trust in your company's ability to assist me during this challenging time. Your prompt attention to this matter is greatly appreciated.

Please contact me at (555) 123-4567 or [email protected] to discuss this further or to request any additional information you may need.

Thank you for your assistance in this matter, and I look forward to your prompt response.

Sincerely,

John Smith
50 changes: 50 additions & 0 deletions lab-materials/03/llm_usage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import os

from langchain.llms import HuggingFaceTextGenInference
from langchain.chains.combine_documents.stuff import StuffDocumentsChain
from langchain.chains import LLMChain
from langchain.prompts import PromptTemplate
from langchain.evaluation import load_evaluator
from langchain.embeddings import HuggingFaceEmbeddings

INFERENCE_SERVER_URL = os.environ.get("LLM_ENDPOINT")
MAX_NEW_TOKENS = 512
TOP_K = 10
TOP_P = 0.95
TYPICAL_P = 0.95
TEMPERATURE = 0.01
REPETITION_PENALTY = 1.03

def infer_with_template(input_text, template):
llm = HuggingFaceTextGenInference(
inference_server_url=INFERENCE_SERVER_URL,
max_new_tokens=MAX_NEW_TOKENS,
top_k=TOP_K,
top_p=TOP_P,
typical_p=TYPICAL_P,
temperature=TEMPERATURE,
repetition_penalty=REPETITION_PENALTY,
streaming=True,
verbose=False,
)

PROMPT = PromptTemplate.from_template(template)

llm_chain = LLMChain(llm=llm, prompt=PROMPT)

return llm_chain.run(input_text)

def similarity_metric(predicted_text, reference_text):
embedding_model = HuggingFaceEmbeddings()
evaluator = load_evaluator("embedding_distance", embeddings=embedding_model)
distance_score = evaluator.evaluate_strings(prediction=predicted_text, reference=reference_text)
return 1-distance_score["score"]

if __name__ == '__main__':
with open('example_text.txt') as f:
input_text = f.read()

with open('template.txt') as f:
template = f.read()

summarize_with_template(input_text, template)
3 changes: 3 additions & 0 deletions lab-materials/03/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
langchain==0.0.340
text_generation==0.6.1
sentence_transformers==2.2.2
Loading

0 comments on commit 420ca71

Please sign in to comment.