Qwen-Math menyediakan kemampuan reasoning dan perhitungan matematika yang kuat, berserta langkah-langkah pemecahan masalah yang rinci untuk memudahkan pemahaman dan verifikasi.
Dokumen ini hanya berlaku untuk wilayah China (Beijing). Untuk menggunakan model, gunakan Kunci API dari wilayah tersebut.
Model dan harga
Komersial
Model | Harga input | Harga output | Context window | Input maksimum | Output maksimum | Kuota gratis |
(Juta token) | (Token) | |||||
qwen-math-plus | $0,574 | $1,721 | 4.096 | 3.072 | 3.072 | Tidak ada kuota gratis |
qwen-math-turbo | $0,287 | $0,861 | ||||
Snapshots sepertiqwen-math-xxx-latestdanqwen-math-xxx-YYYY-MM-DDmemiliki harga dan spesifikasi yang sama dengan versiqwen-math-xxxsebelumnya.
Kemampuan model:qwen-math-xxx=qwen-math-xxx-latest=qwen-math-xxx-2024-09-19
Open source
Model | Harga input | Harga output | Context window | Input maksimum | Output maksimum | Kuota gratis |
(Juta token) | (Tokens) | |||||
qwen2.5-math-72b-instruct | $0,574 | $1,721 | 4.096 | 3.072 | 3.072 | Tidak ada kuota gratis |
qwen2.5-math-7b-instruct | $0,144 | $0,287 | ||||
qwen2.5-math-1.5b-instruct | Gratis untuk sementara waktu | Gratis untuk sementara waktu | ||||
Untuk informasi selengkapnya mengenai rate limit, lihat Rate limits.
Memulai
Anda harus memperoleh kunci API dan mengatur API key sebagai variabel lingkungan. Jika Anda menggunakan OpenAI SDK atau DashScope SDK untuk melakukan panggilan, Anda juga perlu menginstal SDK.
Kompatibel dengan OpenAI
Python
from openai import OpenAI
import os
client = OpenAI(
api_key=os.getenv("DASHSCOPE_API_KEY"), # Jangan hard-code kredensial dalam kode Anda. Selalu gunakan variabel lingkungan atau layanan manajemen kunci.
base_url="https://dashscope.aliyuncs.com/compatible-mode/v1",
)
completion = client.chat.completions.create(
model="qwen-math-plus",
messages=[{'role': 'user', 'content': 'Turunkan solusi universal untuk persamaan kuadrat $ Ax^2+Bx+C=0 $'}])
print(completion.choices[0].message.content)curl
curl --location "https://dashscope.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": "Turunkan solusi universal untuk persamaan kuadrat $ Ax^2+Bx+C=0 $"
}
]
}'DashScope
Python
from http import HTTPStatus
import dashscope
def call_with_messages():
messages = [
{'role': 'user', 'content': 'Turunkan solusi universal untuk persamaan kuadrat $ 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()
Java
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;
public class Main {
public static void callWithMessage()
throws NoApiKeyException, ApiException, InputRequiredException {
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
curl --location "https://dashscope.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"
}
}'Anda juga dapat membuka Konsol Studio Model untuk mencoba model tersebut.
Rekomendasi
Gunakan bahasa Inggris dan LaTeX: Qwen-Math dirancang untuk menangani soal matematika dalam bahasa Inggris. Untuk hasil terbaik, gunakan LaTeX untuk simbol dan rumus matematika dalam input Anda.
Standarisasi output: Gunakan partial mode untuk kontrol presisi. Fitur ini memastikan output mengikuti awalan yang diberikan secara akurat, sehingga meningkatkan akurasi dan kendali atas hasilnya.
Secara default, parameter
temperaturemodel diatur ke 0. Anda tidak perlu menggantinya.Dapatkan hasil dengan mudah: Secara default, Qwen-Math menempatkan hasil akhir di dalam blok
\boxed{}.
FAQ
Bagaimana cara menggunakan Qwen-Math untuk memecahkan soal matematika dalam gambar? |
Qwen-Math tidak mendukung input berupa gambar.
Untuk informasi selengkapnya tentang parameter input dan respons Qwen-Math, lihat referensi API Qwen. |
Di mana saya dapat menemukan informasi detail mengenai kode error? |
Jika panggilan gagal, lihat Pesan error untuk troubleshooting. |