Model Qwen-Math menyediakan penalaran matematika dengan solusi langkah demi langkah yang terperinci dan dapat diverifikasi.
CatatanDokumen ini hanya berlaku untuk wilayah China (Beijing). Untuk menggunakan model ini, Anda harus menggunakan API key dari wilayah China (Beijing).
Model dan harga
Model KomersialNama model | Harga input | Harga output | Context window | Input maks | Output maks | Kuota gratis |
|---|---|---|---|---|---|---|
(per juta token) | (token) | |||||
qwen-math-plus | $0,574 | $1,721 | 4.096 | 3.072 | 3.072 | Tidak tersedia kuota gratis. |
qwen-math-turbo | $0,287 | $0,861 | ||||
Untuk informasi tentang pembatasan laju model, lihat rate limiting.
Memulai dengan cepat
Dapatkan Kunci API dan ekspor Kunci API sebagai Variabel lingkungan. Jika Anda menggunakan OpenAI SDK atau SDK DashScope untuk melakukan panggilan, instal SDK.
Kompatibel dengan OpenAI
from openai import OpenAI
import os
client = OpenAI(
api_key=os.getenv("DASHSCOPE_API_KEY"), # Untuk keamanan, jangan hard-code Kunci API Anda. Gunakan variabel lingkungan atau layanan manajemen rahasia.
# Wilayah China (Beijing). URL berbeda tergantung wilayahnya.
base_url="https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
)
completion = client.chat.completions.create(
model="qwen-math-plus",
messages=[{'role': 'user', 'content': 'Derive a universal solution for the quadratic equation $ Ax^2+Bx+C=0 $'}])
print(completion.choices[0].message.content)
curl --location "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1/chat/completions" \
--header "Authorization: Bearer $DASHSCOPE_API_KEY" \
--header "Content-Type: application/json" \
--data '{
"model": "qwen-math-plus",
"messages": [
{
"role": "user",
"content": "Derive a universal solution for the quadratic equation $ Ax^2+Bx+C=0 $"
}
]
}'
DashScope
from http import HTTPStatus
import dashscope
# Wilayah China (Beijing). URL berbeda tergantung wilayahnya.
dashscope.base_http_api_url = 'https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1'
def call_with_messages():
messages = [
{'role': 'user', 'content': 'Derive a universal solution for the quadratic equation $ Ax^2+Bx+C=0 $'}]
response = dashscope.Generation.call(
model='qwen-math-plus',
messages=messages,
# Atur result_format ke 'message'.
result_format='message',
)
if response.status_code == HTTPStatus.OK:
print(response)
else:
print('Request id: %s, Status code: %s, error code: %s, error message: %s' % (
response.request_id, response.status_code,
response.code, response.message
))
if __name__ == '__main__':
call_with_messages()
import java.util.Arrays;
import com.alibaba.dashscope.aigc.generation.Generation;
import com.alibaba.dashscope.aigc.generation.GenerationResult;
import com.alibaba.dashscope.aigc.generation.GenerationParam;
import com.alibaba.dashscope.common.Message;
import com.alibaba.dashscope.common.Role;
import com.alibaba.dashscope.exception.ApiException;
import com.alibaba.dashscope.exception.InputRequiredException;
import com.alibaba.dashscope.exception.NoApiKeyException;
import com.alibaba.dashscope.utils.Constants;
public class Main {
public static void callWithMessage()
throws NoApiKeyException, ApiException, InputRequiredException {
// Wilayah China (Beijing). URL berbeda tergantung wilayahnya.
Constants.baseHttpApiUrl="https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1";
Generation gen = new Generation();
Message userMsg = Message.builder().role(Role.USER.getValue()).content("Derive a universal solution for the quadratic equation $ Ax^2+Bx+C=0 $").build();
GenerationParam param =GenerationParam.builder()
.apiKey(System.getenv("DASHSCOPE_API_KEY"))
.model("qwen-math-plus")
.messages(Arrays.asList(userMsg))
.resultFormat(GenerationParam.ResultFormat.MESSAGE)
.build();
GenerationResult result = gen.call(param);
System.out.println(result);
}
public static void main(String[] args){
try {
callWithMessage();
} catch (ApiException | NoApiKeyException | InputRequiredException e) {
System.out.println(e.getMessage());
}
}
}
curl --location "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/services/aigc/text-generation/generation" \
--header "Authorization: Bearer $DASHSCOPE_API_KEY" \
--header "Content-Type: application/json" \
--data '{
"model": "qwen-math-plus",
"input":{
"messages":[
{
"role": "user",
"content": "Derive a universal solution for the quadratic equation $ Ax^2+Bx+C=0 $"
}
]
},
"parameters": {
"result_format": "message"
}
}'
Coba model di Konsol Model Studio.
Rekomendasi
- Gunakan bahasa Inggris dan LaTeX: Qwen-Math menangani soal matematika dalam bahasa Inggris. Gunakan LaTeX untuk simbol dan rumus dalam input Anda.
- Kontrol output konten: Mode sebagian memastikan output model mengikuti awalan yang diberikan secara ketat, sehingga meningkatkan akurasi.
- Parameter
temperaturesecara default bernilai0. Jangan ubah pengaturan ini. - Ekstraksi hasil dengan mudah: Qwen-Math secara default menampilkan hasil akhir dalam blok
\boxed{}.
### Final Answer:
The universal solution for the quadratic equation $ Ax^2 + Bx + C = 0 $ is:
$$
\boxed{x = \frac{-B \pm \sqrt{B^2 - 4AC}}{2A}}
$$
Pertanyaan yang sering diajukan
Bagaimana cara menyelesaikan soal matematika dalam gambar dengan Qwen-Math? |
Qwen-Math tidak mendukung pengenalan gambar.
Parameter input dan output Qwen-Math didokumentasikan dalam Referensi API Qwen. |
Di mana saya bisa menemukan detail kode kesalahan? |
Jika pemanggilan model gagal dan mengembalikan pesan kesalahan, lihat Kode kesalahan untuk solusinya. |