Fix processing to handle subset of descriptions and match DataFrame length
Browse files
app.py
CHANGED
@@ -12,15 +12,18 @@ async def process_csv(file):
|
|
12 |
df = pd.read_csv(file, header=None) # Read the CSV file without a header
|
13 |
descriptions = df[0].tolist() # Access the first column directly
|
14 |
SAMPLE_SIZE = min(5, len(descriptions)) # Adjust sample size as needed
|
15 |
-
|
16 |
|
17 |
-
model_name = "instruction-pretrain/finance-Llama3-8B" #
|
18 |
|
19 |
results = []
|
20 |
-
for desc in
|
21 |
result = await process_text(model_name, desc)
|
22 |
results.append(result)
|
23 |
|
|
|
|
|
|
|
24 |
df['predictions'] = results
|
25 |
return df
|
26 |
|
|
|
12 |
df = pd.read_csv(file, header=None) # Read the CSV file without a header
|
13 |
descriptions = df[0].tolist() # Access the first column directly
|
14 |
SAMPLE_SIZE = min(5, len(descriptions)) # Adjust sample size as needed
|
15 |
+
descriptions_subset = descriptions[:SAMPLE_SIZE]
|
16 |
|
17 |
+
model_name = "instruction-pretrain/finance-Llama3-8B" # or any other model you want to use
|
18 |
|
19 |
results = []
|
20 |
+
for desc in descriptions_subset:
|
21 |
result = await process_text(model_name, desc)
|
22 |
results.append(result)
|
23 |
|
24 |
+
# Fill the rest of the results with empty strings to match the length of the DataFrame
|
25 |
+
results.extend([''] * (len(descriptions) - SAMPLE_SIZE))
|
26 |
+
|
27 |
df['predictions'] = results
|
28 |
return df
|
29 |
|