Update README.md
Browse files
README.md
CHANGED
@@ -8,55 +8,58 @@ https://huggingface.co/TinyLlama/TinyLlama-1.1B-Chat-v1.0 with ONNX weights to b
|
|
8 |
|
9 |
## Usage (Transformers.js)
|
10 |
|
11 |
-
If you haven't already, you can install the [Transformers.js](https://huggingface.co/docs/transformers.js) JavaScript library from [NPM](https://www.npmjs.com/package/@
|
12 |
```bash
|
13 |
-
npm i @
|
14 |
```
|
15 |
|
16 |
**Example:** Text generation with `Xenova/TinyLlama-1.1B-Chat-v1.0`.
|
17 |
|
18 |
```js
|
19 |
-
import { pipeline } from
|
20 |
|
21 |
-
// Create a text
|
22 |
-
const generator = await pipeline(
|
|
|
|
|
|
|
23 |
|
24 |
// Define the list of messages
|
25 |
const messages = [
|
26 |
-
|
27 |
-
|
28 |
-
]
|
29 |
-
|
30 |
-
// Construct the prompt
|
31 |
-
const prompt = generator.tokenizer.apply_chat_template(messages, {
|
32 |
-
tokenize: false, add_generation_prompt: true,
|
33 |
-
});
|
34 |
|
35 |
// Generate a response
|
36 |
-
const
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
// {
|
45 |
-
// generated_text: '<|system|>\n' +
|
46 |
-
// 'You are a friendly assistant.\n' +
|
47 |
-
// '<|user|>\n' +
|
48 |
-
// 'Explain thermodynamics in simple terms.\n' +
|
49 |
-
// '<|assistant|>\n' +
|
50 |
-
// 'Thermodynamics is a branch of physics that deals with the study of heat and its transfer, including the relationship between matter and energy, the concept of chemical equilibrium, and the effects of temperature on chemical and physical processes. In thermodynamics, the properties of matter (such as heat capacity, specific heat, and entropy) are considered and their behavior is studied in relation to the temperature.\n\n' +
|
51 |
-
// 'Here are some simple steps to explain thermodynamics in simple terms:\n\n' +
|
52 |
-
// '1. Energy: Energy is the ability to do work. It is the ability to transfer heat or do other thermodynamic processes. Some common forms of energy are heat, light, electricity, and chemical energy.\n\n' +
|
53 |
-
// '2. Heat: Heat is a form of energy that can be transferred from one place to another. It is the ability to induce a change in the temperature of a body or system.\n\n' +
|
54 |
-
// '3. Heat capacity: Heat capacity is the amount of heat required to raise the temperature of a system by 1 degree Kelvin (K). It is a measure of the ability of a material to absorb and dissipate thermal energy.\n\n' +
|
55 |
-
// '4. Specific heat: Specific heat is the heat required to raise the'
|
56 |
-
// }
|
57 |
-
// ]
|
58 |
|
59 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
|
61 |
---
|
62 |
|
|
|
8 |
|
9 |
## Usage (Transformers.js)
|
10 |
|
11 |
+
If you haven't already, you can install the [Transformers.js](https://huggingface.co/docs/transformers.js) JavaScript library from [NPM](https://www.npmjs.com/package/@huggingface/transformers) using:
|
12 |
```bash
|
13 |
+
npm i @huggingface/transformers
|
14 |
```
|
15 |
|
16 |
**Example:** Text generation with `Xenova/TinyLlama-1.1B-Chat-v1.0`.
|
17 |
|
18 |
```js
|
19 |
+
import { pipeline } from "@huggingface/transformers";
|
20 |
|
21 |
+
// Create a text generation pipeline
|
22 |
+
const generator = await pipeline(
|
23 |
+
"text-generation",
|
24 |
+
"Xenova/TinyLlama-1.1B-Chat-v1.0",
|
25 |
+
);
|
26 |
|
27 |
// Define the list of messages
|
28 |
const messages = [
|
29 |
+
{ role: "system", content: "You are a friendly assistant." },
|
30 |
+
{ role: "user", content: "Explain thermodynamics in simple terms." },
|
31 |
+
];
|
|
|
|
|
|
|
|
|
|
|
32 |
|
33 |
// Generate a response
|
34 |
+
const output = await generator(messages, { max_new_tokens: 512 });
|
35 |
+
console.log(output[0].generated_text.at(-1).content);
|
36 |
+
```
|
37 |
+
|
38 |
+
|
39 |
+
<details>
|
40 |
+
|
41 |
+
<summary>Example output</summary>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
|
43 |
```
|
44 |
+
Thermodynamics is the branch of physics that deals with the study of energy and its transformation. It is a fundamental branch of physics that deals with the behavior of matter and its interactions with heat, work, and energy.
|
45 |
+
|
46 |
+
In simple terms, thermodynamics is the study of how energy is transferred, stored, and released in various systems. It involves the study of the following:
|
47 |
+
|
48 |
+
1. Energy: Thermodynamics deals with the concept of energy, which is the ability to do work or to cause a change in state. It includes the study of energy sources, such as heat, electricity, and chemical reactions, as well as the transfer of energy from one system to another.
|
49 |
+
|
50 |
+
2. Work: Work is the ability to do something with energy. It includes the study of the transfer of work from one system to another, as well as the study of the conversion of energy into work.
|
51 |
+
|
52 |
+
3. Energy transfer: Thermodynamics deals with the transfer of energy from one system to another. It includes the study of the transfer of energy between different types of systems, such as heat transfer between two bodies, chemical reactions, and electrical circuits.
|
53 |
+
|
54 |
+
4. Energy storage: Thermodynamics also deals with the storage of energy. It includes the study of the transfer of energy from one system to another, as well as the study of the conversion of energy into different forms.
|
55 |
+
|
56 |
+
5. Energy conversion: Thermodynamics deals with the conversion of energy from one form to another. It includes the study of the transfer of energy from one system to another, as well as the study of the conversion of energy into different forms.
|
57 |
+
|
58 |
+
In summary, thermodynamics is the study of how energy is transferred, stored, and released in various systems. It involves the study of energy sources, such as heat, electricity, and chemical reactions, as well as the transfer of energy from one system to another, the conversion of energy into different forms, and the storage of energy.
|
59 |
+
```
|
60 |
+
|
61 |
+
</details>
|
62 |
+
|
63 |
|
64 |
---
|
65 |
|