Views
No views yet
1from lorax import Client
2
3client = Client("http://<your_endpoint>")
4
5review = "<your product review>"
6
7prompt = f"""
8Below is the text from a review from an Amazon user for a product they
9purchased. Please predict how many stars they gave the product in their
10review.
11
12Review: {review}
13
14Number of stars:
15"""
16
17adapter_id = "tgaddair/mistral-7b-amazon-reviews-lora-r8"
18resp = client.generate(prompt, max_new_tokens=64, adapter_id=adapter_id)
19print(resp.generated_text)1model_type: llm
2input_features:
3 - name: prompt
4 type: text
5 preprocessing:
6 max_sequence_length: null
7 column: prompt
8output_features:
9 - name: stars
10 type: text
11 preprocessing:
12 max_sequence_length: null
13 column: stars
14prompt:
15 template: >-
16 Below is the text from a review from an Amazon user for a product they
17 purchased. Please predict how many stars they gave the product in their
18 review.
19
20
21 Review: {text}
22
23
24 Number of stars:
25preprocessing:
26 split:
27 type: random
28 probabilities:
29 - 0.95
30 - 0
31 - 0.05
32 global_max_sequence_length: 2048
33adapter:
34 type: lora
35generation:
36 max_new_tokens: 64
37trainer:
38 type: finetune
39 epochs: 3
40 optimizer:
41 type: paged_adam
42 batch_size: 1
43 eval_steps: 100
44 learning_rate: 0.0002
45 eval_batch_size: 2
46 steps_per_checkpoint: 1000
47 learning_rate_scheduler:
48 decay: cosine
49 warmup_fraction: 0.03
50 gradient_accumulation_steps: 16
51 enable_gradient_checkpointing: true
52base_model: mistralai/Mistral-7B-v0.1
53quantization:
54 bits: 4