pe-llm-0 / few-shot-pe-llm-0.py
kolkata97's picture
Update few-shot-pe-llm-0.py
eee335b
def few_shot_pe_llm_0():
pipe = pipeline("text-classification", model="kolkata97/autotrain-pe-llm-0")
predicted_categories = []
for sentence in sentences_list:
results = pipe(sentence)
predicted_categories.append(results[0]['label'])
with open(output_csv_file, 'r', newline='', encoding='utf-8') as file:
csv_reader = csv.reader(file)
rows = list(csv_reader)
for i, row in enumerate(rows[1:], start=0):
row.append(predicted_categories[i])
with open(output_csv_file, 'w', newline='', encoding='utf-8') as file:
writer = csv.writer(file)
writer.writerows(rows)
print("Predicted categories appended to the CSV file.")