QwenLM / Qwen2

Qwen2 is the large language model series developed by Qwen team, Alibaba Cloud.
7.29k stars 440 forks source link

Qwen2-72B-ins-gptq-int4 非常喜欢用英文回答问题,即使指定了中文。 #800

Open iwanglei1 opened 1 month ago

iwanglei1 commented 1 month ago

在给定参考资料上回答问题时,非常偏向英文输出。使用prompt或者system控制仍然无效。 image image image

iwanglei1 commented 1 month ago

难受 非常难受 image

jklj077 commented 1 month ago

it should not happen. what frameworks are you using? it is likely the framework is doing something weird.

iwanglei1 commented 1 month ago

I am using the vllm 0.5.1 framework.

jklj077 commented 1 month ago

Hi, I wonder if you could share the full case for us to reproduce, including the messages (the system message, the user input, any previous history contexts, etc.), and generation configurations (temperature, top_k, top_p, repetition penalty and such).

iwanglei1 commented 1 month ago

system message: 你是一个基于Qwen的人工智能助手,你的名字叫豆豆。 user input: 介绍下文章的主要内容。文章内容 Doi: 10.1016@j.jpba.2012.03.009 history:[],History is not used. temperature:0.7, top_k:20, top_p:0.8, repetition penalty:1.05 max_model_len:1024*8 max_num_seqs:20 enforce_eager:True

jklj077 commented 1 month ago

Hi, thank you for sharing the case! I can indeed reproduce the issue. However, it appears that there is a workaround: placing the instruction at the end of the user input.

In []: print(messages) # For educational purposes; only content publicly accessible from https://www.sciencedirect.com/science/article/abs/pii/S073170851200132X
[{'role': 'system', 'content': '你是一个基于Qwen的人工智能助手,你的名字叫豆豆。'}, {'role': 'user', 'content': "Review\nApplication of the near-infrared spectroscopy in the pharmaceutical technology\nAuthor links open overlay panel\nMarzena Jamrógiewicz\n\nAbstract\nNear-infrared (NIR) spectroscopy is currently the fastest-growing and the most versatile analytical method not only in the pharmaceutical sciences but also in the industry. This review focuses on recent NIR applications in the pharmaceutical technology. This article covers monitoring, by NIR, of many manufacturing processes, such as granulation, mixing or drying, in order to determine the end-point of these processes. In this paper, apart from basic theoretical information concerning the NIR spectra, there are included determinations of the quality and quantity of pharmaceutical compounds. Some examples of measurements and control of physicochemical parameters of the final medicinal products, such as hardness, porosity, thickness size, compression strength, disintegration time and potential counterfeit are included. Biotechnology and plant drug analysis using NIR is also described. Moreover, some disadvantages of this method are stressed and future perspectives are anticipated.\n\nHighlights\n► This work presents NIR spectroscopy application in the pharmaceutical manufacturing. ► The physical point of view on NIR is shown also with the spectra interpretation. ► A collection of multi-thematic data, also contains aspects of bio-manufacturing. ► NIR quality controlling system of pharmaceuticals and biopharmaceuticals is verified. ► Implementation of NIR method on the contrary to scientific knowledge is pointed out.\n\nIntroduction\nInfrared spectral measurements have been used for a broad range of applications – from analysis of liquids, gas compositions and solid substances to detailed characterization of each physical state. One of the fundamental properties of chemical bonds is that they exhibit vibrations at distinct frequencies. The vibrational frequency of a chemical bond is intrinsic to the chemical bond of interest [1]. The electromagnetic energy of molecular vibration is defined as near-infrared (from 120 to 400 THz, from 2500 to 750 nm or from 12,500 to 4000 cm−1), infrared, or mid-infrared (from 30 to 120 THz, from 2500 to 25,000 nm or from 4000 to 40 cm−1) and far-infrared between 300 GHz and 30 THz (that is from 25,000 nm to 1,000,000 nm). Infrared radiation absorbed by an individual molecule causes particular bonds to vibrate in a manner which is similar to that of a diatomic oscillator. Therefore, it is convenient to start from the diatomic molecule as the simplest vibrating system and then extend the concept to polyatomic molecules. Changes in light energy between the three regions of infrared lead to varying absorptions of different molecules and bonds, inducing different types of vibrations. For instance, the least energetic far infrared region of light (FIR) is absorbed by heavy atoms, such as some inorganic and organometallic substances, while the mid infrared area (MIR) is used for organic chemical analyses.\n\nNear-infrared (NIR) spectroscopy was not a popular technique until 1960s. The current triumph of this method is owed to Karl Norris who recognized the potential of the use of NIR in industrial practice for measurements of certain types of food, agricultural components [2] and product quality control. This method gained wide acceptance within the pharmaceutical industry, particularly for the analysis of intact dosage forms and process monitoring [3], and it could be applied for liquid, slurry, powdered or solid samples.\n\nA potential molecule, intended to be analyzed by NIR spectroscopy, should possess the change of dipole moment and also a large mechanical anharmonicity of the vibrating atoms [4]. Therefore, a large variety of compounds is appropriate for analysis in the range of near-infrared. Characteristic features of the NIR spectrum are overtones and combination bands of CH, OH and NH functionalities which dominate the spectrum, whereas the corresponding overtones resulting from the fundamental absorption values of the most intense MIR area are rarely represented [5]. Overtones (electron excitations to higher energy levels) are similar to octaves in a musical scale, like harmonics of the fundamental vibrational frequencies [6]. Combination bands are the sum of two different vibrations corresponding to different chemical bonds. Although the absorbance values of combination bands and overtones are smaller than transitions ones, in bulk materials (for example pharmaceuticals) this feature is an advantage because of the material's properties, which allow obtaining high absorbance values.\n\nUnfortunately, because of the overlapping of overtones and combination of vibrations NIR spectra are much more complicated for interpretation [7]. The total NIR spectrum contains up to four overtones from the absorptions of methyl (Csingle bondH), methylene (Csingle bondH), methoxy (Csingle bondH), aromatic (Csingle bondH), carbonyl associated (Csingle bondH) groups, Nsingle bondH from primary and secondary amides, Nsingle bondH from amines (primary, secondary, and tertiary), Nsingle bondH of amine salts, Osingle bondH (alcohols and water), Ssingle bondH, or Cdouble bondO groups [8]. In some papers clarification of spectroscopic signals and wavenumber ranges characteristic for each vibration–harmonics could be found [9].\n\nOver the last few years near-infrared spectroscopy has developed into indispensable tool for academic research and industrial quality control in a wide field of applications, from the synthetic chemistry to the agriculture and from some life sciences to the environmental analysis. It is the crucial method also in the pharmaceutical area, mainly in such branches as technology, microbiology, toxicology, counterfeit detection, determination of physicochemical properties, stability testing and also quality control of a final product. Pharmaceutical technology needs NIR spectroscopy for implementation of in- and on-line processes control in many phases of manufacturing process (Fig. 1) [10], [11], [12], [13].\n\nThe identification of specific wavelength regions is needed when changes in the signal obtained from the near-infrared spectrometer indicate the changes which are proportional to the concentration of chemical components of pharmaceuticals, or represent the physical characteristics of samples under analysis. Generally, qualitative and quantitative analysis performed by near-infrared spectroscopic methods requires the application of multivariate calibration algorithms (MCA), and, eventually, the usage of some chemometric methods essential for model spectral response to chemical or physical properties of a calibration or learning model set. It is possible and also quite recommended to create the spectral library of standard pharmaceutical materials using NIR spectroscopy as a rapid, non-invasive technique for compound identification [14]. Very useful information about characteristic bands of active pharmaceutical ingredients (APIs) or excipients is contained in recent publications [15]. There is also a need for verification and identification of such simple compounds or residual solvents as methanol and ethanol in pharmaceutical products. Two-dimensional (2D) correlation near-infrared spectroscopy sometimes is very useful for difficult and not typical analysis. This technique is useful for discovery of some special vibration modes that cannot be clearly seen in the original spectra. In example it is suited to distinguish between specific bands for methanol and ethanol which are not clearly observed in the combination vibration region of spectrum (5000–4500 cm−1) [16].\n\nNIR spectroscopy is a valuable diagnostic tool which can be used for elucidation of comprehensive structural information of numerous biological samples. The comprehensive vibrational spectroscopic studies were performed for a group of newly developed synthetic biopolymers. In this case, NIR spectra result mainly from these vibrational regions which could be divided into:\n-\nthe first overtone of the hydroxyl stretching region;\n\n-\nthe second overtone of the Csingle bondH stretching mode, which could be found in the high wavenumber region between 9000 and 6500 cm−1;\n\n-\nthe first overtone of the Csingle bondH stretching vibrations, which could be found in the 5900–5350 cm−1 region;\n\n-\nthe combination of Osingle bondH stretching (mode) and second overtone of the Cdouble bondO stretching mode, arising in the lower wavenumber region between 5300 and 4800 cm−1 [17].\n\n\nThe assignment of NIR absorption bands is important for simple band identification of active compound contained in a formulation [18], as well as for the recognition of reaction product and also for the monitoring in the synthesis reactor. Petter et al. presented a simple NIR spectroscopy method for monitoring of the peptide reaction between oxytocin and glutathione [19]. A qualitative model of analysis allowed rapid identification of newly produced conjugates, while a quantitative method was aimed at determination of the amount of oxytocin and glutathione degradation products.\n\nA number of data and detailed spectra structure correlations have been presented in a comprehensive handbook by Workman and may be helpful during interpretation of NIR spectra [10]. Author described the increased interest of spectroscopists, particularly these involved in implementation of process of near-infrared measurements, in this spectral region. Moreover, some examples of useful near-infrared absorption bands are presented in a book about NIR implementation by Katherine Bakeev [9].\n\nSection snippets\nRecommendations for NIR application in the pharmaceutical sciences\nAdvanced medicinal products require new generations of pharmaceutical manufacture which must be ready for improved quality control of each step in the unit process of dosage form development [20]. In 2003, the Food and Drug Administration Agency (FDA) announced Pharmaceutical Current Good Manufacturing Practices (cGMPs) for the 21st century in order to modernize all the regulations and to get a better knowledge of the production processes. This document is recommended and respected all over the \n\nNIR in the pharmaceutical chemistry and physicochemistry\nNear-infrared spectroscopy provides a rapid analysis of a wide range of materials, giving a possibility of obtaining a large number of chemical and physicochemical parameters or even chemical composition of some formulations as well. Various pharmaceutical parameters from tablet technology, such as hardness, particle size, compaction force, dissolution rate, or water content, can be quantitatively analyzed by NIR spectroscopy [3], [28]. Good standard of granulation step is acquired due to such\n\nSteps of pharmaceutical technology, controlled by NIR\nThere are many industrial or scientific reports about the usage of near-infrared spectroscopy for API determination not only directly in a formulation, but also as a raw material or during different manufacturing processes [10], [11], [12], [13]. The latter depends on homogeneity of the formulation and compound's stability. A non-destructive NIR method of drug content prediction has recently been presented in various aspects:\n-\ndetermination of API in a case of powders with different particle\n\n\nPlant drug analysis\nIn the last 40 years near-infrared spectroscopy became one of the most useful methods for analysis not only strictly pharmaceutical compounds but also proteins, dry matter of plant extracts or carbohydrates quantity in many agriculture related products and plant materials [3]. Some of them are intended to become medicinal products. Recently, the use of NIR spectroscopy in determination of some minor compounds such as alkaloids, tocopherols, phenolic and glycoside compounds, glucosinolates, or\n\nBiotechnological medicinal products tested by NIR spectroscopy\nApart from applications in pharmaceutical technology, chemistry or industry, near-infrared spectroscopy has also successfully been applied in the biotechnology field. Using near-infrared dyes, it is possible to analyze DNA and protein molecules [92], to detect some genetically modified organisms by comparison of their DNA fragments [93], and above all, to examine the activities and roles of a particular gene expression in some seed phenotypes with regard to their physiochemical composition [94]\n\nDisadvantages of NIR spectroscopy\nNear-infrared spectroscopy possesses several advantages over other analytical techniques used in the pharmaceutical technology but there are also some disadvantages of this method (Table 2).\n\nOne of the main disadvantages of NIR spectroscopy used in pharmaceutical technology is a problem with aqueous environment (solutions of medicinal products or active pharmaceutical ingredients alone) for direct quantity determinations. High absorbance of water, which leads to a broad peak on a spectrum,\n\nConclusions\nThere are many applications of near-infrared spectroscopy in the pharmaceutical technology. In addition, many difficult technological problems in the scientific or industrial field may be solved due to this popular PAT tool. NIR spectra band depends on the physical or chemical nature of the sample and allows its identification as well as determination of physical or chemical parameters of the sample. The advantages of NIR spectroscopy method are numerous: non-invasive and non-destructive\n\n介绍下文章主要内容"}]

In []: completion = client.chat.completions.create(model=model, messages=messages, temperature=0.7, top_p=0.8, extra_body={"repetition_penalty": 1.05, "top_k": 20})

In []: print(completion.choices[0].message)
ChatCompletionMessage(content='这篇文章主要讨论了近红外光谱法(Near-Infrared Spectroscopy, NIR)在制药技术中的应用。作者Marzena Jamrógiewicz详细阐述了NIR如何 被用于监测制药过程中的多个步骤,如造粒、混合或干燥,以确定这些过程的终点。文章不仅涵盖了基础理论信息,如NIR光谱的解释,还探讨了使用NIR确定药物化合物的质量和数量,以及测量和控制成品药物的物理化学参数,如硬度、孔隙率、厚度、压缩强度、崩解时间和潜在的假冒产品。\n\n此外,文章还提到了NIR在生物技术和植物药物分析中的 应用,强调了该方法的一些缺点,并展望了未来的发展方向。例如,NIR光谱法在生物技术领域可用于分析DNA和蛋白质分子,检测转基因生物,以及研究特定基因表达对种子表型的影响。然而,NIR的一个主要缺点是在水性环境中直接定量测定药物或活性成分时面临的挑战,因为水的高吸收会导致光谱上的宽峰。\n\n总的来说,文章强调了NIR作为一种非侵入性和无损检测工具,在制药技术中具有广泛的应用前景,能够解决许多科学和工业领域的复杂问题,是过程分析技术(Process Analytical Technology, PAT)的重要组成部分。', role='assistant', function_call=None, tool_calls=[])

In []: completion = client.chat.completions.create(model=model, messages=messages, temperature=0.7, top_p=0.8, extra_body={"repetition_penalty": 1.05, "top_k": 20})

In []: print(completion.choices[0].message)
ChatCompletionMessage(content='该文章主要讨论了近红外光谱技术在制药科技中的应用、优势、挑战及未来展望。以下是文章的主要内容概览:\n\n### 近红外光谱技术的崛 起与应用\n- **发展历程**:近红外光谱技术直到1960年代才开始受到重视,其广泛应用得益于Karl Norris对其潜力的发掘,尤其是在食品和农产品质量控制方面的应用。\n- **制药行业中的应用**:近红外光谱技术在制药行业的应用日益广泛,特别是在药品完整剂型分析和过程监控方面,可用于液体、浆糊、粉末或固体样品的分析。\n\n### 技术原 理与特征\n- **原理**:近红外光谱技术依赖于分子振动中偶极矩的变化和原子振动的机械非谐性,适用于多种化合物的分析。\n- **光谱特征**:近红外光谱主要由CH、OH和NH官能团的倍频和组合带主导,这些特征对于复杂材料的高吸收值有利。\n\n### 制药科技中的具体应用\n- **过程监测**:用于监控制造过程如造粒、混合或干燥的终点,确保产品质量。\n- **物理化学参数测定**:可以测量最终医药产品的硬度、孔隙率、厚度尺寸、压缩强度、崩解时间和潜在的假冒产品。\n- **生物技术和植物药物分析**:应用于蛋白质、植物提取物干物质以及农业相关产品的定量分析。\n\n### 优缺点与未来展望\n- **优点**:非侵入性、无损检测,快速提供大量化学和物理化学参数。\n- **缺点**:水环境下的直接定量分析困难,光谱解释复杂。\n- **未来方向**:尽管存在挑战,但近红外光谱技术在制药科技领域的应用前景广阔,有望进一步优化药品生产过程和质量控制。\n\n总之,文章全面地探讨了近红外光谱技术在制药科技中的重要作用,从理论基础到实际应用,再到面临的技术挑战,为读者提供了深入的理解和前瞻性的思考。', role='assistant', function_call=None, tool_calls=[])

In []: completion = client.chat.completions.create(model=model, messages=messages, temperature=0.7, top_p=0.8, extra_body={"repetition_penalty": 1.05, "top_k": 20})

In []: print(completion.choices[0].message)
ChatCompletionMessage(content='该文章主要讨论了近红外光谱技术(Near-Infrared Spectroscopy, NIR)在制药科技中的应用与进展。NIR作为一种快速且多功能的分析方法, 在制药科学和工业中得到了广泛应用。文章概述了NIR在监测制药过程(如造粒、混合或干燥)终点的应用,以及在确定药物成分的质量和数量方面的使用。它不仅涵盖了成品药 物理化参数(如硬度、孔隙率、厚度、压缩强度、崩解时间和假冒检测)的测量与控制,还涉及了生物技术和植物药物分析。\n\n文章亮点包括:\n1. 展示了NIR在制药生产中的应用。\n2. 提供了从物理角度对NIR的理解及其光谱解释。\n3. 汇总了多主题数据,包括生物制造方面。\n4. 验证了NIR作为药品和生物制药质量控制系统的作用。\n5. 指出了NIR方法实施中可能存在的科学知识差距。\n\nNIR技术的兴起归功于Karl Norris,他在20世纪60年代认识到NIR在食品、农业成分和产品质量控制中的潜力。NIR适用于液体、浆 状、粉末或固体样品,因其能检测分子中具有偶极矩变化和大原子非谐振性的化合物而成为理想选择。\n\n然而,NIR光谱的复杂性在于过频和组合带的重叠,这使得信号解释更 具挑战性。尽管如此,NIR光谱仍能提供CH、OH和NH基团的特征信息,对于批量材料而言,这是其优势所在。文章强调了NIR在制药技术各个阶段的在线和离线过程控制中的重要性,包括原料鉴定、反应监控、成品质量测试等。\n\nNIR也被用于生物样本的结构信息解析,例如在合成生物聚合物的研究中。此外,NIR可以用于肽类反应的监测,如在研究催产素与谷胱甘肽之间的反应时,NIR能够快速识别新产生的结合物并定量分析降解产物。\n\n文章最后总结了NIR在制药科技中的广泛应用,并指出了其在解决科学和工业难题方面的潜力。尽管NIR有诸多优点,但文章也提到了一些缺点,如在水环境中直接定量分析的困难,以及需要复杂的校准算法来处理多变量数据。总体而言,NIR为制药行业提供了非侵入性和无损的分析手段,大大提高了药品生产的效率和质量控制水平。', role='assistant', function_call=None, tool_calls=[])
iwanglei1 commented 1 month ago

Thanks for your support.

gg22mm commented 3 weeks ago

什么意思? 似乎有一个解决方法:将指令放在用户输入的末尾。 看不懂?


我现在这样不知道对不对?

< |im_start| >user 发烧了怎么办 用中文来答<|im_end|> < |im_start| >assistant

看着还是有英文的

图片

iwanglei1 commented 3 weeks ago

换个模型试试,或者用Qwen1.5 。感觉Qwen2为了支持多语言,在很多时候中文回复的概率小很多

gg22mm commented 3 weeks ago

我用的是: Qwen2-Math-7B-Instruct

~~

iwanglei1 commented 3 weeks ago

不解数学问题的话,大可不必用这个

gg22mm commented 3 weeks ago

嗯,多谢,我试试 Qwen1.5-7B-Chat

Qwen1.5-7B-Chat 确实是好很多啊 , 没就没这种情况了~~

jklj077 commented 3 weeks ago

@gg22mm hi, if I understand correctly, the response from your screenshot is generated by Qwen2-Math-7B-Instruct. is that correct?

gg22mm commented 3 weeks ago

截图的回复是Qwen2-Math-7B-Instruct生成的,

是的,我已经换成:Qwen1.5-7B-Chat,这个没有问题~~

jklj077 commented 3 weeks ago

@gg22mm Qwen2-Math mainly supports English now. your result is expected. please refer to the blog on this. it has its own GitHub repo here, and for more questions, please ask them there.

DoiiarX commented 2 weeks ago

每天发现一个有意思的bug。。。似乎千问系列的确应该把指令放在末尾。有时候我提示词太长了,效果总是不好。