File size: 2,194 Bytes
bf5fd16 faadec8 bf5fd16 9a7d166 faadec8 9a7d166 e682e58 2730b70 e682e58 1b78dbf 58e6151 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | import streamlit as st
from datasets import load_dataset
# Load your dataset
dataset = load_dataset('csv', data_files='CCI_Details_Structured_Full.csv')
# Title and description
st.title('Contributor Search App')
st.write('Enter the name of a Contributor to search in the dataset.')
# Streamlit widget for user input
contributor_query = st.text_input('Enter Contributor to search:')
# Run the query based on the widget input
if contributor_query: # Check if the user has entered a query
results = [
example for example in dataset['train']
if example.get('Contributor') and example['Contributor'].lower() == contributor_query.lower()
]
st.write(results) # Display the results in the app
from transformers import T5ForConditionalGeneration, T5Tokenizer
from datasets import load_dataset
# Load the T5-small model and tokenizer (or your custom model)
model_name = "Lexim011/NISTER" # Ensure this is the correct string identifier for your model
model = T5ForConditionalGeneration.from_pretrained(model_name)
tokenizer = T5Tokenizer.from_pretrained(model_name)
# Load your dataset
dataset = load_dataset("Lexim011/Compliance")
# Load your dataset (replace with your dataset path or identifier)
dataset = load_dataset("Lexim011/Compliance")
# Example: Encode and generate a response
def generate_answer(question, context):
input_text = f"question: {question} context: {context} </s>"
input_ids = tokenizer.encode(input_text, return_tensors="pt")
outputs = model.generate(input_ids)
answer = tokenizer.decode(outputs[0], skip_special_tokens=True)
return answer
# Example usage with your dataset
# Assuming your dataset has 'question' and 'context' columns
for example in dataset['train']:
# Use 'Definition' as the question
definition = example['Definition']
# Use 'References' or another field as context (if needed)
context = example['References']
# Generate an answer based on the definition and context
answer = generate_answer(definition, context)
# Print out the results
print(f"Definition: {definition}")
print(f"References: {context}")
print(f"Answer: {answer}")
print("---")
|