Spaces:
Build error
Build error
Commit History
-
Create weaviate_utils.py
ed8aec1 -
Update app.py
33d813d -
Update requirements.txt
f1ea802 -
Update app.py
41bf6ed -
added debugging features
3b3c852 -
Update app.py
f790556 -
Update app.py
a17d0ff -
Update app.py
6b58ffb -
Update app.py
d0de0d8 -
Update app.py
04376ef -
Added map_dtype_to_weaviate function
a4a1c61 -
modified ingest_data_to_weaviate function
modified def ingest_data_to_weaviate(dataframe, class_name, class_description): # Create class schema class_schema = { "class": class_name, "description": class_description, "properties": [] # Start with an empty properties list } # Try to create the class without properties first try: client.schema.create({"classes": [class_schema]}) except weaviate.exceptions.SchemaValidationException: # Class might already exist, so we can continue pass # Now, let's add properties to the class for column_name, data_type in zip(dataframe.columns, dataframe.dtypes): property_schema = { "name": column_name, "description": f"Property for {column_name}", "dataType": [map_dtype_to_weaviate(data_type)] } try: client.schema.property.create(class_name, property_schema) except weaviate.exceptions.SchemaValidationException: # Propert…203bb0f -
Update app.py
4758881 -
Update app.py
dfcdc4f -
Weaviate schema based on user input and csv upload
UI Input for Class and Description: We'll add an input field in the Streamlit app where users can define the class name and description of the CSV they're uploading. Auto-Populate Schema from CSV: Once the CSV is uploaded, we'll read its headers to determine the column names. We can then use simple heuristics to determine the data type of each column (e.g., if a column contains only numbers, it's likely a float or int, if it matches date patterns, it's a date, otherwise, it's a string). We'll also use the column names as descriptions for simplicity, but this can be enhanced further if needed. Create Schema in Weaviate: Using the class name, description, and the auto-populated properties, we'll define the schema and create it in Weaviate. Ingest Data: Once the schema is created, we can then ingest the data from the CSV into Weaviate.b9d05c0 -
Update app.py
46ad3c2 -
Updated weaviate.Client ()
# Initialize Weaviate client for the embedded instance client = weaviate.Client( embedded_options=EmbeddedOptions() )27ba167 -
Update requirements.txt
0129317 -
Update requirements.txt
dfe2e05 -
added weaviate
91e60c0 -
added embedded weaviate client and ingest_data + query_weaviate functions
from copy import deepcopy import streamlit as st import pandas as pd from io import StringIO from transformers import AutoTokenizer, AutoModelForTableQuestionAnswering import numpy as np import weaviate # Initialize TAPAS model and tokenizer tokenizer = AutoTokenizer.from_pretrained("google/tapas-large-finetuned-wtq") model = AutoModelForTableQuestionAnswering.from_pretrained("google/tapas-large-finetuned-wtq") # Initialize Weaviate client for the embedded instance client = weaviate.Client("http://localhost:8080") # Function to ingest data into Weaviate def ingest_data_to_weaviate(dataframe): for index, row in dataframe.iterrows(): obj = { "class": "YourClassName", "id": str(index), "properties": row.to_dict() } client.data_object.create(obj) # Function to query data from Weaviate def query_weaviate(question): # This is a basic example; adapt the query based on the question results = client.query.get('YourClass…0e62360
-
Update app.py
45ee012 -
Update app.py
66f9f66 -
Update app.py
072f6c1 -
Update app.py
d133a84 -
Update app.py
af37abc -
Update app.py
3a49d30 -
more iloc errors and (str)
The iloc operation seems to be returning a single value (in this case, a string) rather than a Series or DataFrame. This is why you're seeing the error 'str' object has no attribute 'values'. The error iloc cannot enlarge its target object suggests that we're trying to access an index that might be out of bounds. Based on these issues, I propose the following adjustments: Replace .values with .item() for scalar values, which will safely convert single values to their respective native Python types. Add some additional checks and logging to understand the shape and type of data you're working with.515be2e -
more error handling
def ask_llm_chunk(chunk, questions): chunk = chunk.astype(str) try: inputs = tokenizer(table=chunk, queries=questions, padding="max_length", truncation=True, return_tensors="pt") except Exception as e: st.write(f"An error occurred: {e}") return ["Error occurred while tokenizing"] * len(questions) # Check for token limit if inputs["input_ids"].shape[1] > 512: st.warning("Token limit exceeded for chunk") return ["Token limit exceeded for chunk"] * len(questions) outputs = model(**inputs) predicted_answer_coordinates, predicted_aggregation_indices = tokenizer.convert_logits_to_predictions( inputs, outputs.logits.detach(), outputs.logits_aggregation.detach() ) st.write(f"Testing DataFrame iloc: {chunk.iloc[0, 8]}") # Debugging line answers = [] for coordinates in predicted_answer_coordinates: if len(coordinates) == 1: try: st.write(f"T…c1ca766 -
additional error handling for chunking and indeces
7cd6a5a -
Errors on chunking and cordinates
Token shape: 512: This means the model should be able to handle this without exceeding the token limit, which is good. Type of coordinates[0]: <class 'tuple'>: This shows that the coordinates are tuples, which means we have to use them as indices in a different way. Value of coordinates[0]: (0, 8): This likely indicates the row and column indices, respectively. An error occurred: 'str' object has no attribute 'values': This means that chunk.iloc[coordinates[0]].values is a string and doesn't have the attribute "values." We need to fix this line. An error occurred: iloc cannot enlarge its target object: This could indicate an indexing error and needs further investigation. Let's start by addressing these issues. The coordinates being a tuple suggest that they should be used as (row, column) indices directly. The 'str' object has no attribute 'values' error suggests that we might need to remove .values from chunk.iloc[coordinates[0]].values.5539883 -
Had an error about incorrect type (str) so adding error handling to debug
def ask_llm_chunk(chunk, questions): chunk = chunk.astype(str) try: inputs = tokenizer(table=chunk, queries=questions, padding="max_length", truncation=True, return_tensors="pt") st.write(f"Token shape: {inputs['input_ids'].shape[1]}") # Debugging line # Check for token limit if inputs["input_ids"].shape[1] > 512: st.warning("Token limit exceeded for chunk") return ["Token limit exceeded for chunk"] * len(questions) outputs = model(**inputs) predicted_answer_coordinates, predicted_aggregation_indices = tokenizer.convert_logits_to_predictions( inputs, outputs.logits.detach(), outputs.logits_aggregation.detach() ) answers = [] for coordinates in predicted_answer_coordinates: st.write(f"Type of coordinates[0]: {type(coordinates[0])}") # Debugging line st.write(f"Value of coordinates[0]: {coordinates…b1fc865 -
Still getting tokenization and chunking errors
Errors: The error Token indices sequence length is longer than the specified maximum sequence length for this model (5183 > 512) clearly indicates that the tokenized sequence length is exceeding the model's limit, which is 512 tokens for TAPAS. The exception ValueError: Unable to create tensor, you should probably activate truncation and/or padding with 'padding=True' 'truncation=True' to have batched tensors with the same length. suggests that you should enable truncation to cut the token sequence down to a manageable size. Fix: Enable truncation in the tokenizer. Possibly reduce the chunk size if the above step doesn't resolve the issue. Notice the truncation=True argument in the tokenizer method. This will truncate the token sequence to fit the model's maximum input size. Also, I've included a try-except block to capture any exceptions that may occur during tokenization.414bc96 -
iloc errors around chunking and token length plus script for allowing ctrl+enter submissions
Errors: FutureWarnings: These are warnings indicating that the code is using deprecated features that may be removed in future versions of the libraries. While not urgent, it's good to address these warnings to future-proof your code. You can replace 'DataFrame.swapaxes' with 'DataFrame.transpose'. Replace instances where you use Series.__getitem__ as positions with Series.iloc. Token indices sequence length: This indicates that the tokenized input sequence is longer than the maximum allowed length for the model (512 tokens for TAPAS). You need to manage the size of your input sequence. Also added script to accept "Ctrl+Enter" as Submit512f2de -
Update requirements.txt
cd0ba3c -
import numpy as np
missing import numpy as np2cc5fad -
Still debugging errors
This version includes: Exception handling to catch and display errors. Reduced the MAX_ROWS_PER_CHUNK to 50 to further mitigate the token limit issue. Additional error messages to help you understand what's going wrong.5e71278 -
updated to fix indexing error
Error: Token indices sequence length is longer than the specified maximum sequence length for this model (5187 > 512). This suggests that your input sequence length is exceeding the maximum allowable sequence length for the model. TAPAS, like many other transformer models, has a maximum input sequence length. In this case, it's 512 tokens. IndexError: iloc cannot enlarge its target object This is the error related to pandas, where it's not allowed to assign a value to an index that doesn't exist in the DataFrame. Attempted Fix: I've added checks to ensure that token count doesn't exceed the model's limit. I've added debugging print statements to help you understand what's going on.6674859 -
initial requirements commit
0704eb2 -
Initial commit
b0e4f45 -
initial commit
e2061d5