├── LICENSE ├── README.md ├── data ├── eval │ └── 药品适应症评测数据集.csv └── train │ └── sft-20k.json ├── gradio_cama-demo.py ├── gradio_chatglm_demo.py ├── gradio_chinese-llama_demo.py ├── lora └── lora_weights ├── pics ├── llm_kg1.jpg ├── llm_kg2.jpg └── medcopilot1.jpg ├── requirements.txt └── scripts ├── callbacks.py ├── merge_llama_plus.sh └── merge_llama_with_chinese_lora.py /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 启真医学大模型 & MedCopilot 2 | 3 | ## QiZhenGPT 4 | 5 | QiZhenGPT: An Open Source Chinese Medical Large Language Model 6 | 7 | 8 | 本项目利用[启真医学知识库](http://www.mk-base.com)构建的中文医学指令数据集,并基于此在[Chinese-LLaMA-Plus-7B](https://github.com/ymcui/Chinese-LLaMA-Alpaca)、[CaMA-13B](https://github.com/zjunlp/CaMA)、[ChatGLM-6B](https://github.com/THUDM/ChatGLM-6B)模型上进行指令精调,大幅提高了模型在中文医疗场景下效果,首先针对药品知识问答发布了评测数据集,后续计划优化疾病、手术、检验等方面的问答效果,并针对医患问答、病历自动生成等应用展开拓展。 9 | 10 | ## MedCopilot 11 | 12 | `MedCopilot`是一款基于`启真医学大模型`、[启真医学知识库](http://www.mk-base.com)、`医疗临床数据`研发的智慧医疗助手,旨在为患者、医生和医院管理提供全面的智慧支持。通过整合先进的人工智能技术、丰富的医学知识和临床数据,MedCopilot将成为医疗行业的新质生产力。 13 | 14 | MedCopilot目前已在[浙江大学第二附属医院正式上线使用](https://mp.weixin.qq.com/s/Pm519Et1POgoerkcdC2YRQ)。 15 | 16 | image-20230525165523821 17 | 18 | ## 更新记录 19 | 20 | ### 更新 21 | 22 | [2024/08/09] 更新MedCopilot相关信息; 23 | 24 | [2023/06/27] 开源启真医学大模型体验版(QiZhen-CaMA-13B-Checkpoint-12400),旨在提高医学领域疾病、药品知识问答的准确性; 25 | 26 | [2023/06/09] 开源启真医学大模型体验版(QiZhen-CaMA-13B-Checkpoint-6000),旨在提高医学领域药品知识问答的准确性; 27 | 28 | [2023/06/02] 开源启真医学大模型体验版(QiZhen-CaMA-13B-Checkpoint-3600),旨在提高医学领域药品知识问答的准确性; 29 | 30 | [2023/05/30] 开源[20k](./data/train/sft-20k.json)训练数据(该数据集来自于启真医学知识库收集整理的真实医患知识问答数据以及在启真医学知识库的药品文本知识基础上,通过对半结构化数据设置特定的问题模板构造的指令数据); 31 | 32 | [2023/05/30] 开源启真医学大模型体验版(QiZhen-ChatGLM-6B- Checkpoint-2500),旨在提高医学领域药品知识问答的准确性; 33 | 34 | [2023/05/25] 开源[药品适应症评测数据集](./data/eval/%E8%8D%AF%E5%93%81%E9%80%82%E5%BA%94%E7%97%87%E8%AF%84%E6%B5%8B%E6%95%B0%E6%8D%AE%E9%9B%86.csv); 35 | 36 | [2023/05/24] 开源启真医学大模型体验版(QiZhen-Chinese-LLaMA-7B- Checkpoint-6000),旨在提高医学领域药品知识问答的准确性; 37 | 38 | [2023/05/23] 开源启真医学大模型体验版(QiZhen-Chinese-LLaMA-7B- Checkpoint-3500),旨在提高医学领域药品知识问答的准确性; 39 | 40 | ## MedCopilot功能细节 41 | 42 | ### 1. 功能清单助手 43 | 44 | MedCopilot与 HIS系统和电子病历系统深度融合,利用启真医学大模型分析各个系统数据,自动汇总医生当日重要的工作事项。 45 | 46 | 1. 入院患者统计与分析; 47 | 2. 手术情况统计与分析; 48 | 3. 会诊情况统计与分析; 49 | 4. 文书书写情况统计与分析; 50 | 5. 重点患者统计与分析; 51 | 52 | ### 2. 辅助诊疗助手 53 | 54 | MedCopilot结合启真医学知识库和患者临床数据,提供个性化诊断和治疗建议,帮助医生做出更准确的医疗决策。 55 | 56 | ### 3. 医疗质量助手 57 | 58 | MedCopilot依据国家医疗质量政策,实时监控医疗过程数据,及时发现和纠正潜在问题,提升整体医疗质量。 59 | 60 | ### 4. 病历文书助手 61 | 62 | MedCopilot综合分析患者诊疗数据,自动生成符合规范的病历文书,减少医生的重复性工作,提高工作效率。 63 | 64 | ### 5. 其他功能 65 | 66 | 1. 科研助手:论文解读 67 | 2. 健康助手:报告解读、慢病管理 68 | 69 | ## QizhenGPT细节 70 | 71 | ### 指令数据集构建 72 | 73 | 目前大多数开源的ChatLLM项目使用的是其他模型(如:ChatGPT)生成的指令数据,其不可避免的存在数据幻想的问题,数据幻想问题将严重影响LLM在实际场景中的应用和拓展。因此,本项目为了提高医疗领域的知识问答的准确性,使用如下方式构造指令数据集: 74 | 75 | 1. 启真医学知识库收录的真实医患知识问答数据(疾病、药品、检查检验、手术、预后、食物等),共计`560K`条指令数据; 76 | 2. 药品知识数据:在启真医学知识库的药品文本知识基础上,通过对半结构化数据设置特定的问题模板(如:“{药品}的适应病症是什么?”)构造指令数据集,共计`180K`条指令数据; 77 | 3. 疾病知识数据:在启真医学知识库的疾病文本知识基础上,通过对半结构化数据设置特定的问题模板(如:“{疾病}的典型症状是什么?”)构造指令数据集,共计`298K`条指令数据; 78 | 79 | ### 训练细节 80 | 81 | 1. QiZhen-Chinese-LLaMA-7B- Checkpoint-3500:本项目基于[Chinese-LLaMA-Plus-7B](https://github.com/ymcui/Chinese-LLaMA-Alpaca)进行指令微调,该项目在7张A800(80G)上进行训练,本次开源的是LoRA权重为训练过程中的第`3500 steps`(训练23h50min) ; 82 | 2. QiZhen-Chinese-LLaMA-7B- Checkpoint-6000:本项目基于[Chinese-LLaMA-Plus-7B](https://github.com/ymcui/Chinese-LLaMA-Alpaca)进行指令微调,该项目在7张A800(80G)上进行训练,本次开源的是LoRA权重为训练过程中的第`6000 steps`(训练40h56min); 83 | 3. QiZhen-ChatGLM-6B- Checkpoint-2500:本项目基于[ChatGLM-6B](https://github.com/THUDM/ChatGLM-6B)进行指令微调,该项目在7张A800(80G)上进行训练,本次开源的是LoRA权重为训练过程中的第`2500 steps`(训练16h20min); 84 | 4. QiZhen-CaMA-13B-Checkpoint-3600:本项目基于[CaMA-13B](https://github.com/zjunlp/CaMA)进行指令微调,该项目在7张A800(80G)上进行训练,本次开源的是LoRA权重为训练过程中的第`3600 steps`(训练37h37min)。 85 | 5. QiZhen-CaMA-13B-Checkpoint-6000:本项目基于[CaMA-13B](https://github.com/zjunlp/CaMA)进行指令微调,该项目在7张A800(80G)上进行训练,本次开源的是LoRA权重为训练过程中的第`6000 steps`(训练54h30min)。 86 | 6. QiZhen-CaMA-13B-Checkpoint-12400:本项目基于[CaMA-13B](https://github.com/zjunlp/CaMA)进行指令微调,该项目在6张A800(80G)上进行训练,本次开源的是LoRA权重为训练过程中的第`12400 steps`(训练114h46min)。 87 | 88 | ### 模型下载 89 | 90 | | 模型 | 指令数据集 | Base Model | LoRA下载 | 91 | | :--------------------------------------: | :--------: | :-------------------: | :----------------------------------------------------------: | 92 | | QiZhen-Chinese-LLaMA-7B- Checkpoint-3500 | 740K | Chinese-LLaMA-Plus-7B | [百度网盘](https://pan.baidu.com/s/1KQIF-dUsL7Nrj8UeNuFUiw?pwd=ivgg) | 93 | | QiZhen-Chinese-LLaMA-7B- Checkpoint-6000 | 740K | Chinese-LLaMA-Plus-7B | [百度网盘](https://pan.baidu.com/s/1KQIF-dUsL7Nrj8UeNuFUiw?pwd=ivgg) | 94 | | QiZhen-ChatGLM-6B- Checkpoint-2500 | 740K | ChatGLM-6B | [百度网盘](https://pan.baidu.com/s/1KQIF-dUsL7Nrj8UeNuFUiw?pwd=ivgg) | 95 | | QiZhen-CaMA-13B-Checkpoint-3600 | 740K | CaMA | [百度网盘](https://pan.baidu.com/s/1KQIF-dUsL7Nrj8UeNuFUiw?pwd=ivgg) | 96 | | QiZhen-CaMA-13B-Checkpoint-6000 | 740K | CaMA | [百度网盘](https://pan.baidu.com/s/1KQIF-dUsL7Nrj8UeNuFUiw?pwd=ivgg) | 97 | | QiZhen-CaMA-13B-Checkpoint-12400 | 1038K | CaMA | [百度网盘](https://pan.baidu.com/s/1KQIF-dUsL7Nrj8UeNuFUiw?pwd=ivgg) | 98 | 99 | ### A Quick Start 100 | 101 | #### QiZhen-Chinese-LLaMA-7B 102 | 103 | 1. 环境安装; 104 | 105 | ```bash 106 | pip install -r requirements.txt 107 | ``` 108 | 109 | 2. 获取Chinese-LLaMA-Plus-7B,详情见[这里](https://github.com/ymcui/Chinese-LLaMA-Alpaca/wiki/%E6%A8%A1%E5%9E%8B%E5%90%88%E5%B9%B6%E4%B8%8E%E8%BD%AC%E6%8D%A2); 110 | 111 | 3. 下载LoRA,将模型下载并放在lora目录下; 112 | 113 | 4. 执行scripts/merge_llama_plus.sh 脚本; 114 | 115 | ``` 116 | sh scripts/merge_llama_plus.sh 117 | ``` 118 | 119 | 5. 修改`gradio_chinese-llama_demo.py`里的模型位置参数; 120 | 5. 启动demo; 121 | 122 | ``` 123 | python gradio_chinese-llama_demo.py 124 | ``` 125 | 126 | #### QiZhen-ChatGLM-6B 127 | 128 | 1. 环境安装; 129 | 130 | ```bash 131 | pip install -r requirements.txt 132 | ``` 133 | 134 | 2. 获取ChatGLM-6B,详情见[这里](https://github.com/THUDM/ChatGLM-6B); 135 | 3. 下载LoRA,将模型下载并放在lora目录下; 136 | 137 | 4. 修改`gradio_chatglm_demo.py`里的模型位置参数; 138 | 139 | 5. 启动demo; 140 | 141 | ``` 142 | python gradio_chatglm_demo.py 143 | ``` 144 | 145 | #### QiZhen-CaMA-13B-Checkpoint-3600 146 | 147 | 1. 环境安装; 148 | 149 | ```bash 150 | pip install -r requirements.txt 151 | ``` 152 | 153 | 2. 获取CaMA,详情见[这里](https://github.com/zjunlp/CaMA#2-1); 154 | 155 | 3. 下载LoRA,将模型下载并放在lora目录下; 156 | 157 | 4. 修改`gradio_cama_demo.py`里的模型位置参数; 158 | 159 | 5. 启动demo; 160 | ``` 161 | python gradio_cama_demo.py 162 | ``` 163 | 164 | ### 预研 165 | 166 | 启真医学大模型坚持“数据+知识双轮驱动”的技术路线,通过大模型技术和医学知识库的紧密结合,融合医疗应用场景中的实际需求,从医学数据治理、医学推理、医患问答、病历自动生成、临床决策辅助支持系统等方面开展迭代研发,助力大模型技术在医疗行业的落地和应用实践。下图是“启真医学知识库辅助大模型生成答案”的案例,该项技术在测试后择机发布。 167 | 168 | image-20230525165523821 169 | 170 | image-20230525165523821 171 | 172 | ### 模型效果对比 173 | 174 | #### 测试1 175 | 176 | - input:非布司他能治疗什么疾病 177 | - ChatGLM:非布司他是一种用于治疗哮喘的新药,属于β2受体激动剂。它已经被批准用于治疗以下疾病: 1. 哮喘:非布司他是一种β2受体激动剂,可以刺激β2受体,从而缓解哮喘症状,包括呼吸困难、气促和胸闷。 2. 慢阻肺:非布司他也可以用于缓解慢阻肺引起的症状,包括呼吸急促、气促和咳嗽。 3. 过敏性鼻炎:非布司他可以减轻过敏性鼻炎引起的症状,包括鼻塞、流涕和打喷嚏。 4. 其他疾病:非布司他也被用于治疗其他疾病,如胡萝卜素血症和皮肤划痕症等。 需要注意的是,非布司他是一种药物,其治疗效果和安全性因人而异,最好在医生的指导下使用。 178 | - ChatGPT:非布司他(Fubuxitam)是一种药物,目前我的知识截至于2021年,不包括最新的医学研究和药物进展。根据我了解到的信息,非布司他是一种血小板凝集抑制剂,通常用于预防和治疗血栓性疾病。它可用于预防心脏病、脑血管疾病(例如中风)、静脉血栓栓塞(例如深静脉血栓形成和肺栓塞)以及其他与血栓形成有关的情况。

然而,由于我无法提供最新的医学信息,我建议您咨询医疗专业人士或药剂师以获取关于非布司他的最新信息,并确切了解它在治疗特定疾病方面的适应症和有效性。 179 | - QiZhen-Chinese-LLaMA-7B- Checkpoint-3500:本品用于痛风患者高尿酸血症的长期治疗。
本品为处方药,必须由医生根据病情开处方拿药,并遵医嘱用药,包括用法、用量、用药时间等。不得擅自按照药物说明书自行用药。 180 | - QiZhen-CaMA-13B-Checkpoint-3600:本品用于痛风患者高尿酸血症的长期治疗。 181 | 182 | #### 测试2 183 | 184 | - Input:氟奋乃静癸酸酯注射液的适应症 185 | 186 | - ChatGLM:氟奋乃静癸酸酯注射液是一种药物,适应症如下: 1. 用于治疗抑郁症、焦虑症和失眠等神经精神症状; 2. 用于治疗癫痫、脑外伤和脑动脉硬化等神经系统疾病; 3. 用于缓解慢性疼痛,如痛经、关节炎等疼痛性疾病; 4. 用于改善学习能力和记忆能力,可用于儿童和青少年的智力开发和改善学习效果; 5. 用于预防艾滋病病毒感染和治疗艾滋病。 氟奋乃静癸酸酯注射液是一种口服用药,通常用于治疗抑郁症、焦虑症和失眠等疾病。需要根据医生的建议来制定治疗方案。使用氟奋乃静癸酸酯注射液时,应遵循医生的建议和药品说明书中的用药方法和剂量。 187 | 188 | - ChatGPT:氟奋乃静癸酸酯注射液(Flumazenil Injection)是一种用于治疗苯二氮䓬类药物(如安定类药物)过量或过度使用所引起的镇静或催眠状态的药物。它作为一种苯二氮䓬类受体拮抗剂,能够逆转苯二氮䓬类药物的中枢神经系统抑制作用。<氟奋乃静癸酸酯注射液主要用于以下适应症:

1. 苯二氮䓬类药物过量:当患者因安定类药物过量或过度使用而出现昏迷、嗜睡、呼吸抑制等症状时,氟奋乃静癸酸酯注射液可用于逆转这些症状。

2. 麻醉中逆转:氟奋乃静癸酸酯注射液可用于在手术或其他麻醉操作结束后逆转苯二氮䓬类药物的镇静效果,帮助患者恢复清醒状态。

3. 诊断用途:氟奋乃静癸酸酯注射液还可用于辅助诊断苯二氮䓬类药物中毒或过量情况。

请注意,氟奋乃静癸酸酯注射液应由专业医生根据具体情况进行合理的使用和监控。在使用该药物之前,应仔细阅读并遵循药物说明书,并遵循医生的指导和建议。 189 | 190 | - QiZhen-Chinese-LLaMA-7B- Checkpoint-3500:本品用于精神分裂症、躁狂症等。 也可用于肌紧张性疼痛。 191 | 192 | - QiZhen-CaMA-13B-Checkpoint-3600:本品用于精神分裂症的各种表现。 193 | 194 | #### 测试3 195 | 196 | - input:藏青果茶有哪些主要作用? 197 | 198 | - ChatGLM:藏青果茶是一种天然的饮品,主要由青果、茶叶、蜂蜜等多种材料制成。它的主要作用包括: 1. 提高免疫力:藏青果茶中含有丰富的营养成分,如维生素C、维生素E等,可以增强人体的免疫力,提高身体的抵抗力,预防疾病的发生。 2. 促进消化:藏青果茶中含有丰富的纤维素,可以促进肠胃蠕动,帮助消化,预防便秘的发生。 3. 抗氧化作用:藏青果茶中的青果提取物具有较强的抗氧化作用,可以清除体内自由基,延缓衰老,预防疾病。 4. 降低血脂:藏青果茶中的茶叶提取物具有一定的降低血脂的作用,可以预防和治疗高血脂症。 5. 改善睡眠:藏青果茶中的蜂蜜具有一定的镇静作用,可以帮助缓解压力,改善睡眠质量,提高身体的自我修复能力。 199 | 200 | - ChatGPT:藏青果茶是一种以藏青果为主要原料制作的茶饮品,据我所知,它具有以下主要作用:

1. 抗氧化作用:藏青果富含多种天然抗氧化剂,如多酚类化合物和维生素C,可帮助清除体内自由基,减缓细胞老化,增强免疫力。

2. 促进消化:藏青果茶具有良好的消化刺激作用,有助于促进胃肠道蠕动,改善消化功能,缓解胃部不适和消化不良。

3. 提供营养:藏青果富含维生素C、维生素E、维生素B群、矿物质等营养物质,饮用藏青果茶可以为身体提供所需的营养元素。

4. 减肥瘦身:藏青果茶被认为具有减肥的效果,它可以促进新陈代谢,加速脂肪分解和燃烧,帮助减少体重和脂肪积累。

5. 抗炎镇痛:藏青果茶含有一些具有抗炎和镇痛作用的成分,可以缓解关节疼痛、肌肉酸痛和头痛等不适。

6. 改善睡眠:藏青果茶有助于放松神经系统,具有镇静和安抚作用,可以改善睡眠质量,缓解失眠问题。

需要注意的是,以上作用主要是基于藏青果茶的传统用途和某些研究结果,具体效果因人而异,且可能受到个体差异和使用方式的影响。如果您有特定的健康问题或需要服用药物,建议咨询医生或专业保健人员的建议。 201 | 202 | - QiZhen-Chinese-LLaMA-7B- Checkpoint-3500:清热解毒、生津止渴。 可缓解发热、口渴、咽喉肿痛等症状。 203 | 204 | - QiZhen-CaMA-13B-Checkpoint-3600:藏青果茶具有清热利咽、消肿止痛的功效。 205 | 206 | 藏青果茶可以用于缓解咽喉红肿疼痛、咽干灼热、声音嘶哑等症状。 207 | 208 | #### 测试4 209 | 210 | - input:赖特综合征临床表现有哪些? 211 | 212 | - ChatGLM:赖特综合征(赖特综合征I型)是一种先天性心脏杂音,其临床表现包括: 213 | 214 | 1. 心脏杂音:赖特综合征I型的特征性心脏杂音是卵圆孔未闭引起的右向左分流杂音,通常表现为杂音强度、位置和频率的变异性。 215 | 216 | 2. 肺动脉高压:赖特综合征I型患者通常患有肺动脉高压,这可能导致呼吸衰竭和心脏功能衰竭。 217 | 218 | 3. 生长发育异常:大多数赖特综合征I型患者在儿童和青少年时期会表现出生长发育异常,如身材矮小、营养不良和巨人症。 219 | 220 | 4. 心脏结构异常:尽管杂音是赖特综合征I型的主要临床表现,但部分患者也可能患有其他心脏结构异常,如心脏瓣膜疾病和心律失常。 221 | 222 | 5. 其他症状:赖特综合征I型患者可能还具有其他症状,如疲劳、呼吸困难、胸痛、咳嗽、腹胀和便秘等。这些症状可能与其心脏杂音和肺动脉高压有关,但也可能与其他因素有关。 223 | 224 | 需要注意的是,赖特综合征I型是一种罕见的疾病,其临床表现可能因个体差异而有所不同。如果怀疑自己患有赖特综合征I型,请及时咨询医生进行诊断和治疗。 225 | 226 | - ChatGPT:赖特综合征是指胃食管反流病(GERD)引起的下食管括约肌失弛缓和食管蠕动减弱所导致的一种疾病。它的主要临床表现包括: 227 | 228 | 1. 吞咽困难:患者在吞咽时有被卡住的感觉,需要多次咽喉才能将食物吞咽下去。 229 | 230 | 2. 胸痛:赖特综合征的患者常常出现胸痛,特别是在吃饭或者躺下之后容易加重。 231 | 232 | 3. 嗳气和反酸:患者常感到嗳气和反酸,特别是在吃完饭或者躺下之后。 233 | 234 | 4. 声音嘶哑:由于口腔和喉咙区域受到反流物的刺激,患者的声音可能变得嘶哑。 235 | 236 | 5. 喉咙痛:反流物刺激喉咙黏膜所致。 237 | 238 | 需要注意的是,赖特综合征的症状与其他疾病相似,因此需要通过相关检查和诊断方法确定诊断。 239 | 240 | - QiZhen-CaMA-13B-Checkpoint-12400:赖特综合征的主要临床表现为急性或慢性关节炎、尿道炎、结膜炎及皮肤黏膜病变等。 241 | 242 | 赖特综合征是一种病因不明的慢性非特异性炎症性疾病,属于血清阴性脊柱关节炎的一种,其特征是反复发作性、游走性、不对称性的多关节炎,可伴有尿道炎、结膜炎、皮肤黏膜及眼部病变。 243 | 244 | 赖特综合征的主要临床表现为急性或慢性关节炎、尿道炎、结膜炎及皮肤黏膜病变等。 245 | 246 | 1.关节炎:最常见,任何关节均可受累,以膝、踝和足部小关节多见,局部可有红、肿、热、痛和功能障碍。 247 | 248 | 2.尿道炎:表现为尿频、尿急、尿痛、尿道口红肿、尿道分泌物增多等。 249 | 250 | 3.结膜炎:表现为单侧或双侧结膜炎症,可有结膜充血、水肿、眼睑浮肿、分泌物增多等。 251 | 252 | 4.皮肤黏膜病变:表现为皮肤脂溢性红斑、生殖器红斑、脓疱疹、皮肤脓疱疹、皮肤溃疡。 253 | 254 | ### 实验评测 255 | 256 | #### 药品适应症评测 257 | 258 | 评测标准:随机选择`94`种药品数据,按照“{药品}的适应病症”组成指令,分别让ChatGPT(gpt3.5)、ChatGLM、QiZhe做出回答,然后请专业的医学人员对三个`模型的答案`与`该药品的药品说明书`进行比对评分,以下是三个评分标准: 259 | 260 | - 标准1:模型答案命中一个适应症则回答正确; 261 | 262 | - 标准2:模型答案命中的适应症数目大于等于药品说明书适应症数目的1/2则回答正确; 263 | 264 | - 标准3:模型答案命中的适应症数目大于等于药品说明书适应症数目的2/3则回答正确; 265 | 266 | | 模型 | 标准1 | 标准2 | 标准3 | 267 | | :-------------------------------------: | :--------: | :--------: | :--------: | 268 | | ChatGLM | 39.36% | 23.16% | 14.74% | 269 | | ChatGPT | 47.87% | 30.85% | 15.96% | 270 | | QiZhen-Chinese-LLaMA-7B-Checkpoint-3500 | 77.66% | 55.32% | 40.00% | 271 | | QiZhen-Chinese-LLaMA-7B-Checkpoint-6000 | 90.43% | 73.40% | 65.96% | 272 | | QiZhen-CaMA-13B-Checkpoint-3600 | 82.29% | 60.62% | 47.92% | 273 | | QiZhen-CaMA-13B-Checkpoint-6000 | 90.43% | 80.85% | **72.34%** | 274 | | **QiZhen-CaMA-13B-Checkpoint-12400** | **91.49%** | **82.98%** | **72.34%** | 275 | 276 | **备注:** 277 | 278 | - 若QiZhen-Chinese-LLaMA-7B-Checkpoint-6000:回复有“复读现象”(我们正在持续修复这个问题),请将`repetition_penalty`参数调大; 279 | - QiZhen-ChatGLM-6B-Checkpoint-2500没有进行评测,因为我们在实验过程中发现ChatGLM在指令微调的过程中不能很好的满足医疗知识事实问答的要求:当要求其回复比较精准时,模型“复读”的现象比较严重;在解决“复读”的问题时,其回答的事实性很差(数据幻想严重); 280 | - QiZhen-CaMA-13B-Checkpoint-3600:该版本回复内容基本没有“复读”现象; 281 | - QiZhen-CaMA-13B-Checkpoint-6000:相较于`QiZhen-CaMA-13B-Checkpoint-3600`我们增大了LoRA的参数量,效果得到了有效的提升; 282 | - 更详细的评测细节和数据后续会开源。 283 | 284 | #### 疾病评测 285 | 286 | 评测标准:随机选择`100`种疾病数据,按照“哪些药物能治疗{疾病}?”、“{疾病}需要做哪些检查?”、“{疾病}的临床表现有哪些?”组成“治疗药物”、“检查检验”、“临床表现”指令,分别让ChatGPT(gpt3.5)、ChatGLM、QiZhen0做出回答,然后请专业的医学人员对三个`模型的答案`与`启真医学知识库疾病知识`进行比对评分,以下是三个评分标准: 287 | 288 | - 标准1:模型答案命中一个“治疗药物”(“检查检验”、“临床表现”)则回答正确; 289 | 290 | - 标准2:模型答案命中的“治疗药物”(“检查检验”、“临床表现”)数目大于等于药品说明书适应症数目的1/2则回答正确; 291 | 292 | - 标准3:模型答案命中的“治疗药物”(“检查检验”、“临床表现”)数目大于等于药品说明书适应症数目的2/3则回答正确; 293 | 294 | | 模型 | 临床表现标准1 | 临床表现标准2 | 临床表现标准3 | 检查检验标准1 | 检查检验标准2 | 检查检验标准3 | 治疗药物标准1 | 治疗药物标准2 | 治疗药物标准3 | 295 | | :----------------------------------: | :-----------: | :-----------: | :-----------: | ------------- | ------------- | ------------- | ------------- | ------------- | ------------- | 296 | | chatglm | 90.00% | 6.00% | 3.00% | 93.00% | 11.00% | 6.00% | 60.00% | 10.00% | 5.00% | 297 | | chatgpt | 94.00% | 11.00% | 4.00% | **97.00%** | 8.00% | 5.00% | 62.00% | 11.00% | 4.00% | 298 | | **QiZhen-CaMA-13B-Checkpoint-12400** | **95.00%** | **15.00%** | **7.00%** | **97.00%** | **20.00%** | **7.00%** | **75.00%** | **36.00%** | **23.00%** | 299 | 300 | 301 | 302 | 303 | ## 致谢 304 | 305 | 此外,本项目基于以下开源项目二次开发,在此对相关项目和研究开发人员表示感谢。 306 | 307 | - [LLaMA](https://github.com/facebookresearch/llama) 308 | - [Standford Alpaca](https://github.com/tatsu-lab/stanford_alpaca) 309 | - [CaMA](https://github.com/zjunlp/CaMA) 310 | - [中文LLaMA & Alpaca大模型](https://github.com/ymcui/Chinese-LLaMA-Alpaca) 311 | 312 | 313 | 314 | ## License及免责声明 315 | 316 | ### License 317 | 318 | 详见[LICENSE](./LICENSE) 319 | 320 | ### 免责声明 321 | 322 | **本项目相关资源仅供学术研究之用,严禁用于商业用途。** 使用涉及第三方代码的部分时,请严格遵循相应的开源协议。模型生成的内容受模型计算、随机性和量化精度损失等因素影响,本项目不对其准确性作出保证。对于模型输出的任何内容,本项目不承担任何法律责任,亦不对因使用相关资源和输出结果而可能产生的任何损失承担责任。 323 | 324 | 325 | 326 | ## 引用说明 327 | 328 | 329 | Technical paper is coming soon. 330 | -------------------------------------------------------------------------------- /data/eval/药品适应症评测数据集.csv: -------------------------------------------------------------------------------- 1 | 药品,药品适应症,医学专家标注的适应病症,instruction 2 | 地屈孕酮片,

本品用于治疗内源性孕酮不足引起的疾病,如痛经、子宫内膜异位症、继发性闭经、月经周期不规则、功能失调性子宫出血、经前期综合征、孕激素缺乏所致先兆性流产或习惯性流产、黄体不足所致不孕症。

,内源性孕酮不足|痛经|子宫内膜异位症|继发性闭经|月经周期不规则|功能失调性子宫出血|经前期综合征,地屈孕酮片的适应病症 3 | 替格瑞洛片,

本品适用于急性冠脉综合征(不稳定性心绞痛、非ST段抬高心肌梗死或ST段抬高心肌梗死)患者,包括接受药物治疗和经皮冠状动脉介入(PCI)治疗的患者,降低血栓性心血管事件的发生率。与氯吡格雷相比,本品可以降低心血管死亡、心肌梗死或卒中复合终点的发生率,两治疗组之间的差异来源于心血管死亡和心肌梗死,而在卒中方面无差异。在ACS患者中,对本品与阿司匹林联合用药进行了研究。结果发现,阿司匹林维持剂量大于1mg会降低替格瑞洛减少复合终点事件的临床疗效,因此,阿司匹林的维持剂量不能超过每日1mg。

,急性冠脉综合征|不稳定性心绞痛|非ST段抬高心肌梗死|ST段抬高心肌梗死,替格瑞洛片的适应病症 4 | 劳拉西泮片,

本品用于焦虑障碍的治疗或用于缓解焦虑症状,以及与抑郁症状相关的焦虑的短期治疗。与日常生活压力相关的焦虑或紧张,通常不需要抗焦虑药的治疗。劳拉西泮长期应用的效果,即应用4个月以上的效果还未经系统的临床研究评估。医师应定期重新评估该药对个体患者的有效性。

,焦虑障碍|焦虑,劳拉西泮片的适应病症 5 | 依托考昔片,

本品用于治疗骨关节炎急性期和慢性期的症状和体征,亦可治疗急性痛风性关节炎。

,骨关节炎急性期|骨关节炎慢性期|急性痛风性关节炎,依托考昔片的适应病症 6 | 左甲状腺素钠片,

本品用于先天性甲状腺功能减退症(克汀病)与儿童及成人的各种原因引起的甲状腺功能减退症的长期替代治疗,也可用于单纯性甲状腺肿,慢性淋巴性甲状腺炎,甲状腺癌手术后的抑制(及替代)治疗,也可用于诊断甲状腺功能亢进的抑制试验。

,先天性甲状腺功能减退症|克汀病|单纯性甲状腺肿|慢性淋巴性甲状腺炎|甲状腺癌手术后,左甲状腺素钠片的适应病症 7 | 盐酸普拉克索片,

本品用于治疗特发性帕金森病的体征和症状,单独(无左旋多巴)或与左旋多巴联用。例如,在疾病后期左旋多巴的疗效逐渐减弱或者出现变化和波动时(剂末现象或“开关”波动),需要应用本品。

,特发性帕金森病,盐酸普拉克索片的适应病症 8 | 莨菪浸膏片,

本品适用于胃十二指肠溃疡和胆、肾、肠等绞痛。

,胃溃疡|十二指肠溃疡|胆绞痛|肾绞痛|肠绞痛,莨菪浸膏片的适应病症 9 | 格隆溴铵片,

本品用于胃、十二指肠溃疡及慢性胃炎等。

,胃溃疡|十二指肠溃疡|慢性胃炎,格隆溴铵片的适应病症 10 | 氨甲环酸片,

本品用于急性或慢性、局限性或全身性原发性纤维蛋白溶解亢进所致的各种出血。弥散性血管内凝血所致的继发性高纤溶状态,在未肝素化前,慎用本品。本品还适用于:

1、前列腺、尿道、肺、脑、子宫、肾上腺、甲状腺、肝等富有纤溶酶原激活物脏器的外伤或手术出血。

2、用作组织型纤溶酶原激活物(t-PA)、链激酶及尿激酶的拮抗物。

3、人工流产、胎盘早期剥落、死胎和羊水栓塞引起的纤溶性出血。

4、局部纤溶性增高的月经过多,眼前房出血及严重鼻出血。

5、用于防止或减轻因子Ⅷ因子Ⅸ缺乏的血友病患者拔牙或口腔手术后的出血。

6、中枢动脉瘤破裂所致的轻度出血,如蛛网膜下腔出血和颅内动脉瘤出血;应用本品止血优于其他抗纤溶药,但必须注意并发脑水肿或脑梗塞的危险性,至于重症有手术指征患者,本品仅可作辅助用药。

7、用于治疗遗传性血管神经性水肿。可减少其发作次数和严重度。

8、血友病患者发生活动性出血,可联合应用本药。

9、可治疗溶栓过量所致的严重出血。

,前列腺外伤|尿道外伤|肺外伤|脑外伤|子宫外伤|肾上腺外伤|甲状腺外伤|肝外伤|手术出血|眼前房出血|严重鼻出血|蛛网膜下腔出血|颅内动脉瘤|遗传性血管神经性水肿,氨甲环酸片的适应病症 11 | 盐酸阿罗洛尔片,

本品用于原发性高血压(轻度-中度)、心绞痛、心动过速性心律失常、原发性震颤。

,轻度原发性高血压|中度原发性高血压|心绞痛|心动过速性心律失常|原发性震颤,盐酸阿罗洛尔片的适应病症 12 | 盐酸达泊西汀片,

本品用于治疗符合下列所有条件的18至64岁男性早泄(PE)患者:

1、阴茎在插入阴道之前、过程当中或者插入后不久,以及未获性满足之前仅仅由于极小的性刺激即发生持续的或反复的射精。

2、因早泄(PE)而导致的显著性个人苦恼或人际交往障碍。

3、射精控制能力不佳。

,早泄,盐酸达泊西汀片的适应病症 13 | 他达拉非片,

本品用于治疗男性勃起功能障碍。需要性刺激以使本品生效。他达拉非不能用于女性。

,男性勃起功能障碍,他达拉非片的适应病症 14 | 枸橼酸氯米芬片,

本品用于诱导下述情况妇女的排卵:下丘脑-垂体机能障碍,包括多囊性卵巢综合征(PCOS);诱导接受辅助受孕技术如体外受精(IVF)而行超数排卵妇女的多卵泡发育。从事不育症治疗时应按照临床医师指导用药。

,下丘脑-垂体机能障碍|多囊性卵巢综合征|辅助受孕|体外受精|不育症,枸橼酸氯米芬片的适应病症 15 | 依非韦伦片,

本品用于与其他抗病毒药物联合治疗HIV-1感染的成人、青少年及儿童。

,HIV-1感染,依非韦伦片的适应病症 16 | 拉替拉韦钾片,

1、本品适用于与其他抗反转录病毒药物联合使用,用于治疗人免疫缺陷病毒(HIV-1)。

2、本品适应症的确立是基于对三个临床对照研究48周时的血浆HIV-1RNA水平进行的分析。这些研究中的两个是在接受过三种抗反转录病毒抑制剂治疗(非核苷类反转录酶抑制剂、核苷类反转录酶抑制剂、蛋白酶抑制剂)并有疾病临床进展的成年患者中进行的。另一个是在既往未治疗的患者中进行的。

3、本品与其他活性药物联合使用时产生治疗应答的可能性更大。

4、在儿童患者中尚无本品的安全性和有效性数据。

,HIV-1感染,拉替拉韦钾片的适应病症 17 | 盐酸沙格雷酯片,

本品适用于改善慢性动脉闭塞症所引起的溃疡、疼痛以及冷感等缺血性诸症状。

,慢性动脉闭塞症,盐酸沙格雷酯片的适应病症 18 | 尼可地尔片,

本品用于冠心病,心绞痛的治疗。

,冠心病|心绞痛,尼可地尔片的适应病症 19 | 盐酸厄洛替尼片,

1、厄洛替尼单药适用于表皮生长因子受体(EGFR)基因具有敏感突变的局部晚期或转移性非小细胞肺癌(NSCLC)患者的治疗,包括一线治疗、维持治疗,或既往接受过至少一次化疗进展后的二线及以上治疗。

2、两项多中心、随机、安慰剂对照的Ⅲ期试验结果显示,厄洛替尼联合含铂化疗方案(卡铂+紫杉醇;或者吉西他滨+顺铂)作为局部晚期或转移的NSCLC患者一线治疗,相对单用含铂化疗未增加临床获益,因此不推荐用于上述情况的一线治疗。

,局部晚期非小细胞肺癌|转移性非小细胞肺癌,盐酸厄洛替尼片的适应病症 20 | 甲磺酸溴隐亭片,

1、内分泌系统疾病:泌乳素依赖性月经周期紊乱和不育症(伴随高或正常泌乳素血症)、闭经(伴有或不伴有泌乳)、月经过少、黄体功能不足和药物诱导的高泌乳激素症(抗精神病药物和高血压治疗药物)。

2、非催乳素依赖性不育症:多囊性卵巢综合症、与抗雌激素联合运用(如:氯底酚胺)治疗无排卵症。

3、高泌乳素瘤:垂体小腺瘤的保守治疗,在手术前抑制腺瘤生长或减少腺瘤的体积,使切除容易进行;术后可用于降低仍然较高的泌乳素水平。

4、肢端肥大症:单独应用或联合放疗、手术等可降低生长激素的血浆水平。

5、抑制生理性泌乳:分娩或流产后通过抑制泌乳来抑制乳腺充血、肿胀,从而可预防产后乳腺炎。

6、良性乳腺疾病:缓和或减轻经前综合症及乳腺结节(或囊性)乳腺疾病相关性乳腺疼痛。

7、神经系统疾病:用于各期自发性和脑炎后所致帕金森病的单独治疗,或与其他抗帕金森病药物联合使用。

,泌乳素依赖性月经周期紊乱|泌乳素依赖性不育症|闭经|月经过少|黄体功能不足|药源性高泌乳激素症|非催乳素依赖性不育症|多囊性卵巢综合征|高泌乳素瘤|垂体小腺瘤|肢端肥大症|良性乳腺疾病|经前综合症|乳腺结节|神经系统疾病|自发性帕金森病,甲磺酸溴隐亭片的适应病症 21 | 维格列汀片,

本品适用于治疗2型糖尿病,当二甲双胍作为单药治疗用至最大耐受剂量仍不能有效控制血糖时,本品可与二甲双胍联合使用。

,2型糖尿病,维格列汀片的适应病症 22 | 恩他卡朋片,

本品可作为标准药物左旋多巴/苄丝肼或左旋多巴/卡比多巴的辅助用药,用于治疗以上药物不能控制的帕金森病及剂末现象(症状波动)。

,剂末现象,恩他卡朋片的适应病症 23 | 盐酸氟西汀分散片,

本品适用于抑郁症、强迫症、神经性贪食症,作为心理治疗的辅助用药,以减少贪食和导泻行为。

,抑郁症|强迫症|神经性贪食症|贪食,盐酸氟西汀分散片的适应病症 24 | 恩曲他滨替诺福韦片,

本品用于与其他抗逆转录病毒药物联用,治疗成人和12岁(含)以上儿童的HIV-1感染。当开始使用本品治疗HIV-1感染时,应考虑下列因素:建议本品不要作为三联核苷治疗方案的一个组分使用;本品不应与恩曲他滨、替诺福韦二吡呋酯、拉米夫定或含有三者的固定剂量复方合并使用;接受过治疗的患者,本品的使用应按照实验室检查结果和患者治疗史进行。

,HIV-1感染,恩曲他滨替诺福韦片的适应病症 25 | 甲泼尼龙片,

糖皮质激素只能作为对症治疗,只有在某些内分泌失调的情况下,才能作为替代药品。甲泼尼龙片可用于非内分泌失调症。

1、风湿性疾病:作为辅助疗法短期使用(帮助患者度过急性期或危重期),用于:银屑病性关节炎、类风湿性关节炎,包括青少年类风湿性关节炎(有些患者可能需要低剂量维持治疗)、强直性脊柱炎急性或亚急性滑囊炎、急性非特异性踺鞘炎、急性痛风性关节炎、创伤后骨关节炎、骨关节炎引发的滑膜炎上踝炎。

2、胶原疾病:用于疾病危重期或作为下列疾病的维持治疗:系统性红斑狼疮、全身性皮肌炎(多肌炎)、风湿性多肌痛、巨细胞关节炎、急性风湿性心肌炎。

3、皮肤疾病:天疱疮、大疱疱疹性皮炎、严重的各类红斑病(Steven-Johnson综合症)、剥脱性皮炎、覃样真菌病、严重的银屑病、严重的脂溢性皮炎。

4、过敏状态:用于控制如下以常规疗法难以处理的严重或损伤机能的过敏性疾病:季节性或全年性过敏性鼻炎、血清病、支气管哮喘、药物过敏反应接触性皮炎、异位性皮炎。

5、眼部疾病:眼部及其附件严重的急慢性过敏和炎症反应,例如:过敏性角膜边缘溃疡眼部带状疱疹、前视网膜炎扩散性后房色素层炎和脉络膜炎交感性眼炎、过敏性结膜炎、角膜炎、脉络膜视网膜炎、视神经炎、虹膜炎、虹膜睫状体炎。

6、呼吸道疾病:有症状的肺部肉牙肿其它方法不能控制的吕弗勒氏综合征(Loeffler’sSyndrome)、铍中毒与适当的抗结核化疗法合用于暴发性或扩散性肺结核吸入性肺炎、血液病、特发性血小板减少性紫癜、继发性血小板减少症、获得性(自身免疫性)溶血性贫血、成红细胞减少症(RBC贫血)、先天性(红细胞)低增生性贫血。

7、肿瘤用于下列疾病的缓解治疗,白血病和淋巴瘤儿童急性白血病。

8、水肿状态用于无尿毒症的自发性或狼疮性性肾病综合征的利尿及缓解蛋白尿。

9、胃肠道疾病帮助患者度过以下疾病的危重期:溃疡性结肠炎、局限性回肠炎。

10、神经系统:各类硬化症的急性恶化脑部肿瘤引起的水肿。

11、其它与适当的抗结核化疗法合用,用于伴有蛛网膜下腔阻塞或趋于阻塞的结核性脑膜炎累及神经或心肌的旋毛虫病。

12、器官移植内分泌失调疾病原发或继发性肾上腺皮质不全(氢化可的松和可的松为首选药物,如有需要,合成的糖皮质激素可与盐皮质激素合用,在婴儿期,盐皮质激素的供给尤为重要)先天性肾上腺增生非化脓性甲状腺炎癌症引起的高钙血症。

,非内分泌失调症|银屑病性关节炎|类风湿性关节炎|青少年类风湿性关节炎|强直性脊柱炎|急性滑囊炎|亚急性滑囊炎|急性非特异性踺鞘炎|急性痛风性关节炎|创伤后骨关节炎|系统性红斑狼疮|全身性皮肌炎|风湿性多肌痛|巨细胞关节炎|急性风湿性心肌炎|天疱疮|大疱疱疹性皮炎|严重红斑病|Steven-Johnson综合症|剥脱性皮炎|覃样真菌病|严重银屑病|严重脂溢性皮炎|季节性过敏性鼻炎|全年性过敏性鼻炎|血清病|支气管哮喘|药物过敏反应|接触性皮炎|异位性皮炎|过敏性角膜边缘溃疡|眼部带状疱疹|前视网膜炎|扩散性后房色素层炎|脉络膜炎|交感性眼炎|过敏性结膜炎|角膜炎|脉络膜视网膜炎|视神经炎|虹膜炎|虹膜睫状体炎|吕弗勒氏综合征|铍中毒|暴发性肺结核|扩散性肺结核|吸入性肺炎|血液病|特发性血小板减少性紫癜|继发性血小板减少症|获得性溶血性贫血|成红细胞减少症|先天性低增生性贫血|白血病|淋巴瘤|儿童急性白血病|溃疡性结肠炎危重期|局限性回肠炎危重期|器官移植内分泌失调疾病|肾上腺皮质不全|先天性肾上腺增生|非化脓性甲状腺炎,甲泼尼龙片的适应病症 26 | 硝呋太尔阴道片,

本品用于细菌性阴道病、滴虫性阴道炎、外阴阴道念珠菌病、阴道混合感染。

,细菌性阴道病|滴虫性阴道炎|外阴阴道念珠菌病|阴道混合感染,硝呋太尔阴道片的适应病症 27 | 酒石酸伐尼克兰片,

本品适用于成人戒烟。

,烟草成瘾,酒石酸伐尼克兰片的适应病症 28 | 酒石酸唑吡坦片,

本品限用于下列情况严重睡眠障碍的治疗:偶发性失眠症、暂时性失眠症。

,偶发性失眠症|暂时性失眠症,酒石酸唑吡坦片的适应病症 29 | 依折麦布片,

1、原发性高胆固醇血症:本品作为饮食控制以外的辅助治疗,可单独或与HMG-CoA还原酶抑制剂(他汀类)联合应用于治疗原发性(杂合子家族性或非家族性)高胆固醇血症,可降低总胆固醇(TC)、低密度脂蛋白胆固醇(LDL-C)、载脂蛋白B(ApoB)。

2、纯合子家族性高胆固醇血症(HoFH):本品与他汀类联合应用,可作为其他降脂治疗的辅助疗法(如LDL-C血浆分离置换法),或在其他降脂治疗无效时用于降低HoFH患者的TC和LDL-C水平。

3、纯合子谷甾醇血症(或植物甾醇血症):本品作为饮食控制以外的辅助治疗,用于降低纯合子家族性谷甾醇血症患者的谷甾醇和植物甾醇水平。

,原发性高胆固醇血症|纯合子家族性高胆固醇血症|纯合子谷甾醇血症,依折麦布片的适应病症 30 | 吡罗昔康贴片,

本品用于缓解骨关节炎、腱鞘炎、肌痛、骨关节痛、外伤后及骨折愈合后引起的疼痛。

,骨关节炎|腱鞘炎|肌痛|骨关节痛,吡罗昔康贴片的适应病症 31 | 匹维溴铵片,

本品用于对症治疗与肠道功能紊乱有关的疼痛、排便异常和胃肠不适;对症治疗与胆道功能紊乱有关的疼痛;为钡灌肠做准备。

,肠道功能紊乱|胆道功能紊乱,匹维溴铵片的适应病症 32 | 马来酸氟伏沙明片,

本品用于抑郁症及相关症状的治疗,强迫症症状治疗。

,抑郁症|强迫症,马来酸氟伏沙明片的适应病症 33 | 氯诺昔康片,

本品适用于手术后急性疼痛、外伤引起的中-重度疼痛、急性坐骨神经痛和腰痛、晚期癌痛,亦可用于慢性腰痛、骨关节炎、类风湿性关节炎和强直性脊柱炎的治疗。

,急性坐骨神经痛|腰痛|晚期癌痛|慢性腰痛|骨关节炎|类风湿性关节炎|强直性脊柱炎,氯诺昔康片的适应病症 34 | 盐酸班布特罗片,

本品用于支气管哮喘、慢性喘息性支气管炎、阻塞性肺气肿和其它伴有支气管痉挛的肺部疾病。

,支气管哮喘|慢性喘息性支气管炎|阻塞性肺气肿|支气管痉挛,盐酸班布特罗片的适应病症 35 | 达格列净片,

1、在饮食和运动基础上,本品可作为单药治疗用于2型糖尿病成人患者改善血糖控制。

2、重要的使用限制:本品不适用于治疗1型糖尿病或糖尿病酮症酸中毒。

,2型糖尿病,达格列净片的适应病症 36 | 比卡鲁胺片,

1、50mg每日:与促黄体生成素释放激素(LHRH)类似物或外科睾丸切除术联合应用于晚期前列腺癌的治疗。

2、150mg每日:用于治疗局部晚期、无远处转移的前列腺癌患者,这些患者不适宜或不愿接受外科去势术或其他内科治疗。

,晚期前列腺癌,比卡鲁胺片的适应病症 37 | 硫酸氨基葡萄糖钾片,

本品适用于全身各关节部位的骨性关节炎,如膝关节、髋关节、脊椎、肩、手、腕关节和踝关节等。

,骨性关节炎|膝关节炎|髋关节炎|脊柱炎|肩关节炎|手关节炎|腕关节炎|踝关节炎,硫酸氨基葡萄糖钾片的适应病症 38 | 琥珀酸索利那新片,

本品适用于膀胱过度活动症患者伴有的尿失禁和/或尿频、尿急症状的治疗。

,膀胱过度活动症,琥珀酸索利那新片的适应病症 39 | 盐酸普萘洛尔片,

1、本品用于作为二级预防,降低心肌梗死死亡率。

2、高血压(单独或与其它抗高血压药合用)。

3、劳力型心绞痛。

4、控制室上性快速心律失常、室性心律失常,特别是与儿茶酚胺有关或洋地黄引起心律失常。可用于洋地黄疗效不佳的房扑、房颤心室率的控制,也可用于顽固性期前收缩,改善患者的症状。

5、减低肥厚型心肌病流出道压差,减轻心绞痛、心悸与昏厥等症状。

6、配合α受体阻滞剂用于嗜铬细胞瘤病人控制心动过速。

7、用于控制甲状腺机能亢进症的心率过快,也可用于治疗甲状腺危象。

,高血压|劳力型心绞痛|室上性快速心律失常|室性心律失常|顽固性期前收缩|心绞痛|心悸|昏厥|甲状腺危象,盐酸普萘洛尔片的适应病症 40 | 恩替卡韦片,

本品适用于病毒复制活跃、血清丙氨酸氨基转移酶(ALT)持续升高或肝脏组织学显示有活动性病变的慢性成人乙型肝炎的治疗。

,慢性乙型肝炎病毒复制活跃期,恩替卡韦片的适应病症 41 | 甲苯磺酸索拉非尼片,

用于治疗不能手术或远处转移的肝细胞癌;治疗不能手术的晚期肾细胞癌。

,肝细胞癌远处转移|晚期肾细胞癌,甲苯磺酸索拉非尼片的适应病症 42 | 利伐沙班片,

1、用于择期髋关节或膝关节置换手术成年患者,以预防静脉血栓形成(VTE)。

2、用于治疗成人深静脉血栓形成(DVT),降低急性DVT后DVT复发和肺栓塞(PE)的风险。

3、用于具有一种或多种危险因素(例如:充血性心力衰竭、高血压、年龄≥75岁、糖尿病、卒中或短暂性脑缺血发作病史)的非瓣膜性房颤成年患者,以降低卒中和全身性栓塞的风险。

,择期髋关节置换手术|择期膝关节置换手术|深静脉血栓形成,利伐沙班片的适应病症 43 | 盐酸莫西沙星片,

本品用于治疗成人(≥18岁)敏感细菌所引起的下列感染:

1、急性细菌性鼻窦炎:由肺炎链球菌、流感嗜血杆菌或卡他莫拉菌引起。由于使用氟喹诺酮类药物(包括盐酸莫西沙星)已有报道发生严重不良反应,且对于一些患者,急性细菌性鼻窦炎有自限性,应在没有其它药物治疗时方可使用盐酸莫西沙星。

2、慢性支气管炎急性发作:由肺炎链球菌、流感嗜血杆菌、副流感嗜血杆菌、肺炎克雷伯菌、甲氧西林敏感的金黄色葡萄球菌或卡他莫拉菌引起。由于使用氟喹诺酮类药物(包括盐酸莫西沙星)已有报道发生严重不良反应,且对于一些患者,慢性支气管炎急性发作有自限性,应在没有其它药物治疗时方可使用盐酸莫西沙星。

3、社区获得性肺炎:由肺炎链球菌(包括多药耐药株)、流感嗜血杆菌、卡他莫拉菌、甲氧西林敏感的金黄色葡萄球菌、肺炎克雷伯菌、肺炎支原体或肺炎衣原体引起。

4、非复杂性皮肤和皮肤组织感染:由甲氧西林敏感的金黄色葡萄球菌或化脓性链球菌引起。

5、复杂性皮肤和皮肤组织感染:由甲氧西林敏感的金黄色葡萄球菌、大肠埃希氏菌、肺炎克雷伯氏菌或阴沟肠杆菌引起。

6、复杂性腹腔内感染:由大肠杆菌、脆弱类杆菌、咽峡炎链球菌、星座链球菌、粪肠球菌、变形杆菌、产气荚膜梭菌、多形类杆菌或消化链球菌属等引起,包括腹腔脓肿。

7、鼠疫,包括成人因鼠疫耶尔森氏杆菌(Y.pestis)引起的肺鼠疫和败血性鼠疫,也可预防鼠疫。由于可行性原因,无法对人类进行有效性临床研究,因此,该适应症仅是基于动物有效性研究数据所确定。

8、不伴有输卵管-卵巢或盆腔脓肿的轻至中度盆腔炎性疾病(即:女性上生殖道感染,包括输卵管炎和子宫内膜炎)。由于淋病奈瑟氏菌对莫西沙星的耐药性增加,不建议本品用于单药治疗轻至中度盆腔炎性疾病,而是应当与另一种合适的抗菌药物(例如:头孢菌素)联合用药,除非能够排除对莫西沙星耐药的淋病奈瑟氏菌。

,急性肺炎链球菌性鼻窦炎|急性流感嗜血杆菌性鼻窦炎|急性卡他莫拉菌性鼻窦炎|慢性支气管炎急性发作|社区获得性肺炎|非复杂性皮肤组织化脓性链球菌感染|复杂性皮肤组织金黄色葡萄球菌感染|复杂性腹腔内大肠杆菌感染|鼠疫|女性上生殖道感染,盐酸莫西沙星片的适应病症 44 | 戊酸雌二醇片,

本品用于治疗主要与自然或人工绝经相关的雌激素缺乏:血管舒缩性疾病(潮热),生殖泌尿道营养性疾病(外阴阴道萎缩,性交困难,尿失禁)以及精神性疾病(睡眠障碍,衰弱);也用于预防原发性或继发性雌激素缺乏所造成的骨质丢失。

,血管舒缩性疾病|潮热|生殖泌尿道营养性疾病|外阴阴道萎缩|性交困难|尿失禁|睡眠障碍|衰弱,戊酸雌二醇片的适应病症 45 | 克霉唑阴道片,

本品用于念珠菌性外阴阴道炎。

,念珠菌性外阴阴道炎,克霉唑阴道片的适应病症 46 | 颠茄磺苄啶片,

本品用于痢疾杆菌引起的慢性菌痢和其他敏感致病菌引起的肠炎等。

,慢性菌痢|肠炎,颠茄磺苄啶片的适应病症 47 | 马来酸多潘立酮片,"

本品用于治疗下列疾病或药物引起的消化功能异常(恶心、呕吐、食欲不振、腹胀、上腹部不适、腹痛、胃烧灼、嗳气等):

48 |

1、成人:慢性胃炎,胃下垂症,反流性食道炎,胃切除症候群,使用抗恶性肿瘤药或左旋多巴等引起的上述诸症状。

49 |

2、儿童:周期性呕吐症,上呼吸道感染症,使用抗恶性肿瘤药等引起的消化功能异常。

",慢性胃炎|胃下垂|反流性食道炎|胃切除症候群|儿童周期性呕吐症|儿童上呼吸道感染症,马来酸多潘立酮片的适应病症 50 | 富马酸比索洛尔片,

本品用于治疗高血压、冠心病(心绞痛)、伴有心室收缩功能减退的中度至重度慢性稳定性心力衰竭。在使用本品前,需要遵医嘱接受ACE抑制剂、利尿剂和选择性使用强心苷类药物治疗。

,高血压|冠心病|心绞痛,富马酸比索洛尔片的适应病症 51 | 阿托伐他汀钙片,

1、高胆固醇血症:原发性高胆固醇血症患者,包括家族性高胆固醇血症(杂合子型)或混合性高脂血症(相当于Fredrickson分类法的IIa和IIb型)患者,如果饮食治疗和其它非药物治疗疗效不满意,应用本品可治疗其总胆固醇(TC)升高、低密度脂蛋白胆固醇(LDL-C)升高、载脂蛋白B(ApoB)升高和甘油三酯(TG)升高。在纯合子家族性高胆固醇血症患者,阿托伐他汀钙可与其它降脂疗法(如低密度脂蛋白血浆透析法)合用或单独使用(当无其它治疗手段时),以降低总胆固醇(TC)和低密度脂蛋白胆固醇(LDL-C)。

2、冠心病:冠心病或冠心病等危症(如糖尿病,症状性动脉粥样硬化性疾病等)合并高胆固醇血症或混合型血脂异常的患者,本品适用于:降低非致死性心肌梗死的风险、降低致死性和非致死性卒中的风险、降低血管重建术的风险、降低因充血性心力衰竭而住院的风险、降低心绞痛的风险。

,高胆固醇血症|冠心病,阿托伐他汀钙片的适应病症 52 | 卡维地洛片,

1、本品用于原发性高血压:可单独使用或与其他抗高血压药特别是噻嗪类利尿剂联合使用。

2、治疗有症状的充血性心力衰竭:卡维地洛用于治疗有症状的充血性心力衰竭可降低死亡率以及心血管事件的住院率,改善病人的一般情况并减慢疾病进展。

3、卡维地洛可作为标准治疗的附加治疗,也可用于不耐受ACEI或没有使用洋地黄、肼苯哒嗪、硝酸盐类药物治疗的病人。

,原发性高血压,卡维地洛片的适应病症 53 | 盐酸依匹斯汀片,

本品用于成人所患的过敏性鼻炎、荨麻疹、湿疹、皮炎、皮肤瘙痒症、痒疹、伴有瘙痒的寻常性银屑病及过敏性支气管哮喘的防治。

,过敏性鼻炎|荨麻疹|湿疹|皮炎|皮肤瘙痒症|痒疹|寻常性银屑病|过敏性支气管哮喘,盐酸依匹斯汀片的适应病症 54 | 替比夫定片,

1、替比夫定用于有病毒复制证据以及有血清转氨酶(ALT或AST)持续升高或肝组织活动性病变证据的慢性乙型肝炎成人患者。

2、本适应症基于核苷类似物初治的、HBeAg阳性和HBeAg阴性的、肝功能代偿的,慢性乙型肝炎成年患者的病毒学、血清学、生化学和组织学应答结果。未在合并HIV、HCV或HDV感染的乙型肝炎患者中评估过替比夫定的作用。未在肝移植患者或失代偿肝病患者中评估过替比夫定的作用。对核苷类似物逆转录酶抑制剂耐药的慢性乙型肝炎患者,尚无应用替比夫定的设计良好的对照研究,但估计其可能与拉米夫定存在交叉耐药。

,慢性乙型肝炎病毒复制活跃期,替比夫定片的适应病症 55 | 环酯红霉素片,

本品用于由敏感菌引起的感染,如扁桃体炎、咽炎、细菌性肺炎、支原体肺炎、口腔炎、军团病、白喉、百日咳、猩红热、红癣、类丹毒、淋病、早期梅毒、软下疳、尿道炎、弯曲菌肠炎、阿米巴肠炎等。

,扁桃体炎|咽炎|细菌性肺炎|支原体肺炎|口腔炎|军团病|白喉|百日咳|猩红热|红癣|类丹毒|淋病|早期梅毒|软下疳|尿道炎|弯曲菌肠炎|阿米巴肠炎,环酯红霉素片的适应病症 56 | 盐酸曲唑酮片,

本品用于治疗各种类型的抑郁症和伴有抑郁症状的焦虑症以及药物依赖者戒断后的情绪障碍。

,抑郁症|焦虑症,盐酸曲唑酮片的适应病症 57 | 盐酸苯海索片,

本品用于帕金森病、帕金森综合征。也可用于药物引起的锥体外系疾患。

,帕金森病|帕金森综合征|药源性锥体外系疾患,盐酸苯海索片的适应病症 58 | 盐酸异丙嗪片,"

1、皮肤粘膜的过敏:本品适用于长期的、季节性的过敏性鼻炎,血管舒缩性鼻炎,接触过敏源或食物而致的过敏性结膜炎,荨麻疹,血管神经性水肿,对血液或血浆制品的过敏反应,皮肤划痕症。必要时可与肾上腺素合用,作为本药的辅助剂。

59 |

2、晕动病:防治晕车、晕船、晕飞机。

60 |

3、镇静、催眠:适用于术前、术后和产科。此外,也可用于减轻成人及儿童的恐惧感,呈浅睡眠状态。

61 |

4、恶心、呕吐的治疗:适用于一些麻醉和手术后的恶心、呕吐,也用于防治放射病性或药源性恶心、呕吐。

62 |

5、术后疼痛;可与止痛药合用,作为辅助用药。

",过敏性鼻炎|血管舒缩性鼻炎|过敏性结膜炎|荨麻疹|血管神经性水肿|皮肤划痕症|晕动病|晕车|晕船|晕飞机|放射病性恶心|药源性恶心|药源性呕吐|术后疼痛,盐酸异丙嗪片的适应病症 63 | 盐酸可乐定片,

本品适用于高血压(不作为第一线用药);高血压急症;偏头痛、绝经期潮热、痛经,以及戒绝阿片瘾毒症状。

,高血压|高血压急症|偏头痛|绝经期潮热|痛经,阿片瘾毒戒绝症状,盐酸可乐定片的适应病症 64 | 熊去氧胆酸片,

本品用于胆固醇型胆结石,形成及胆汁缺乏性脂肪泻,也可用于预防药物性结石形成及治疗脂肪痢(回肠切除术后)。

,胆固醇型胆结石|胆汁缺乏性脂肪泻|药物性结石形成|回肠切除术后脂肪痢,熊去氧胆酸片的适应病症 65 | 复方卡托普利片,

1、高血压,可单独应用或与其他降压药合用。

2、心力衰竭,可单独应用或与强心利尿药合用。

,高血压|心力衰竭,复方卡托普利片的适应病症 66 | 卡托普利片,

本品适用于高血压,心力衰竭。

,高血压|心力衰竭,卡托普利片的适应病症 67 | 黄豆苷元片,

本品适用于高血压病及症状性高血压、冠心病、脑血栓、眩晕症、突发性耳聋的辅助治疗。也可用于妇女更年期综合症。

,高血压|冠心病|脑血栓|眩晕症|突发性耳聋|妇女更年期综合征,黄豆苷元片的适应病症 68 | 阿魏酸钠片,

本品用于缺血性心脑血管病的辅助治疗。

,缺血性心脑血管病,阿魏酸钠片的适应病症 69 | 盐酸舍曲林片,

1、本品用于治疗抑郁症的相关症状,包括伴随焦虑、有或无躁狂史的抑郁症。疗效满意后,继续服用舍曲林可有效地防止抑郁症的复发和再发。

2、本品也用于治疗强迫症。疗效满意后,舍曲林在治疗强迫症两年的时间内,仍保持它的有效性、安全性和耐受性。

,抑郁症|强迫症,盐酸舍曲林片的适应病症 70 | 伏立康唑片,

本品用于治疗侵袭性曲霉病。治疗对氟康唑耐药的念珠菌引起的严重侵袭性感染(包括克柔念珠菌)。治疗由足放线病菌属和镰刀菌属引起的严重感染。本品应主要用于治疗免疫缺陷患者中进行性的、可能威胁生命的感染。

,侵袭性曲霉病|放线病菌属严重感染|镰刀菌属严重感染,伏立康唑片的适应病症 71 | 肌苷片,

本品用于急、慢性肝炎的辅助治疗。

,急性肝炎|慢性肝炎,肌苷片的适应病症 72 | 利血平片,

本品适用于治疗高血压(不推荐为一线用药)。

,高血压,利血平片的适应病症 73 | 氧氟沙星片,

本品用于敏感菌引起的:

1、泌尿生殖系统感染,包括单纯性、复杂性尿路感染、细菌性前列腺炎、淋病奈瑟菌尿道炎或宫颈炎(包括产酶株所致者)。

2、呼吸道感染,包括敏感革兰阴性杆菌所致支气管感染急性发作及肺部感染。

3、胃肠道感染,由志贺菌属、沙门菌属、产肠毒素大肠杆菌、亲水气单胞菌、副溶血弧菌等所致。

4、伤寒。

5、骨和关节感染。

6、皮肤软组织感染。

7、败血症等全身感染。

,泌尿生殖系统感染|尿路感染|细菌性前列腺炎|淋病奈瑟菌尿道炎|宫颈炎|呼吸道感染|支气管感染急性发作|肺部感染|胃肠道感染|伤寒|骨关节感染|皮肤软组织感染|败血症|全身感染,氧氟沙星片的适应病症 74 | 丙戊酸钠片,

本品用于单纯或复杂失神发作、肌阵挛发作,大发作的单药或合并用药治疗,有时对复杂部分性发作也有一定疗效。

,失神发作|肌阵挛发作,丙戊酸钠片的适应病症 75 | 西沙必利片,

本品用于对其它治疗不耐受或疗效不佳的严重胃肠道动力性疾病,如慢性特发性或糖尿病性胃轻瘫、慢性假性肠梗阻、胃食管反流病。

,严重胃肠道动力性疾病|慢性特发性胃轻瘫|糖尿病性胃轻瘫|慢性假性肠梗阻|胃食管反流病,西沙必利片的适应病症 76 | 舒林酸片,

本品用于骨关节炎、类风湿性关节炎、关节强硬性脊椎炎、幼年类风湿性关节炎、关节周的疾病如急性疼痛(急性肩峰下粘液囊炎/冈上肌腱炎)和腱鞘炎、急性痛风性关节炎、疼痛的低背综合症(低背痛,通常通归于腰痛)、上呼吸道感染体征和症状。

,骨关节炎|类风湿性关节炎|关节强硬性脊椎炎|幼年类风湿性关节炎|关节周的疾病|急性疼痛|急性肩峰下粘液囊炎|冈上肌腱炎|腱鞘炎|急性痛风性关节炎|疼痛的低背综合症|呼吸道感染,舒林酸片的适应病症 77 | 联磺甲氧苄啶片,

本品主要用于对本品敏感的细菌所致的尿路感染、肠道感染、成人慢性支气管炎急性发作、急性中耳炎等。

,尿路感染|肠道感染|慢性支气管炎急性发作|急性中耳炎,联磺甲氧苄啶片的适应病症 78 | 碳酸锂缓释片,

本品用于治疗躁狂症,对躁狂和抑郁交替发作的双相情感性精神障碍有很好的治疗和预防复发作用,对反复发作的抑郁症也有预防发作作用。也用于治疗分裂-情感性精神病。

,躁狂症|躁郁症|抑郁症|分裂-情感性精神病,碳酸锂缓释片的适应病症 79 | 曲尼司特片,

本品用于预防和治疗支气管哮喘及过敏性鼻炎。

,支气管哮喘|过敏性鼻炎,曲尼司特片的适应病症 80 | 卡比多巴片,

本品与左旋多巴联合应用,用于帕金森病和帕金森综合征。

,帕金森病|帕金森综合征,卡比多巴片的适应病症 81 | 拉米夫定片,

本品用于伴有丙氨酸氨基转氨酶升高和病毒活动复制的、肝功能代偿的成年慢性乙型肝炎病人的治疗。

,慢性乙型肝炎病毒复制活跃期|慢性乙型肝炎肝功能代偿期,拉米夫定片的适应病症 82 | 复方氯唑沙宗片,

本品用于各种急性骨骼肌损伤。

,急性骨骼肌损伤,复方氯唑沙宗片的适应病症 83 | 白消安片,

本品用于慢性粒细胞白血病的慢性期,对缺乏费城染色体Ph1病人效果不佳。也可用于治疗原发性血小板增多症,真性红细胞增多症等慢性骨髓增殖性疾病。

,慢性粒细胞白血病慢性期|原发性血小板增多症|真性红细胞增多症|慢性骨髓增殖性疾病,白消安片的适应病症 84 | 盐酸土霉素片,

1、本品可作为下列疾病的选用药物:

(1)立克次体病,包括流行性斑疹伤寒、地方性斑疹伤寒、洛矶山热、恙虫病和Q热。

(2)支原体属感染。

(3)衣原体属感染,包括鹦鹉热、性病、淋巴肉芽肿、非特异性尿道炎、输卵管炎、宫颈炎及沙眼。

(4)回归热。

(5)布鲁菌病。

(6)霍乱。

(7)兔热病。

(8)鼠疫。

(9)软下疳。

治疗布鲁菌病和鼠疫时需与氨基糖苷类联合应用。

2、由于目前常见致病菌对本品耐药现象严重,仅在病原菌对本品敏感时,可作为选用药物;对本品敏感的大肠埃希菌、产气肠杆菌、洛菲不动杆菌、志贺菌属、流感嗜血杆菌(仅限于呼吸道感染)和克雷伯菌属(限于呼吸道和泌尿道感染)等革兰阴性杆菌感染。本品不宜用于任何类型的葡萄球菌或溶血性链球菌感染。

3、本品可用于对青霉素类过敏的破伤风、气性坏疽、雅司、梅毒、淋病和钩端螺旋体病以及放线菌属、李斯特菌感染的患者。

4、可用于急性肠道阿米巴病和中、重度痤疮患者作为辅助治疗。

,立克次体病|流行性斑疹伤寒|地方性斑疹伤寒|洛矶山热|恙虫病|Q热|支原体属感染|衣原体属感染|鹦鹉热|性病性淋巴肉芽肿|非特异性尿道炎|输卵管炎|宫颈炎|沙眼|回归热|布鲁菌病|霍乱|兔热病|鼠疫|软下疳|急性肠道阿米巴病|中度痤疮|重度痤疮,盐酸土霉素片的适应病症 85 | 特非那定片,

用于治疗季节性过敏性鼻炎,常年性过敏性鼻炎,急、慢性荨麻疹等。

,季节性过敏性鼻炎|常年性过敏性鼻|急性荨麻疹|慢性荨麻疹,特非那定片的适应病症 86 | 米索前列醇片,

本品用于治疗十二指肠溃疡和胃溃疡,包括关节炎患者由于服用非甾体类抗炎药NSAID所引起的十二指肠溃疡和胃溃疡,保障其仍可继续使用NSAID治疗。本品还可用于预防使用NSAID所引起的溃疡。

,十二指肠溃疡|胃溃疡,米索前列醇片的适应病症 87 | 硝酸甘油片,

本品用于冠心病心绞痛的治疗及预防,也可用于降低血压或治疗充血性心力衰竭。

,冠心病|心绞痛|充血性心力衰竭|血压升高,硝酸甘油片的适应病症 88 | 氯噻酮片,

1、水肿性疾病,排泄体内过多的钠和水,减少细胞外液容量,消除水肿。常见的包括充血性心力衰竭、肝硬化腹水、肾病综合征、急慢性肾炎水肿、慢性肾功能衰竭早期、肾上腺皮质激素和雌激素治疗所致的钠、水潴留。

2、高血压,可单独或与其他降压药联合应用,主要用于治疗原发性高血压。

3、中枢性或肾性尿崩症。

4、肾石症,主要用于预防含钙盐成分形成的结石。

,水肿|充血性心力衰竭|肝硬化腹水|肾病综合征|急慢性肾炎水肿|慢性肾功能衰竭早期|高血压|原发性高血压|中枢性尿崩症|肾性尿崩症|肾石症,氯噻酮片的适应病症 89 | 蛋氨酸片,

本品用于脂肪肝,以及酒精和磺胺等药物引起的肝损害。

,脂肪肝|药物性肝损害,蛋氨酸片的适应病症 90 | 盐酸林可霉素片,

本品适用于敏感葡萄球菌属、链球菌属、肺炎链球菌及厌氧菌所致的呼吸道感染、皮肤软组织感染、女性生殖道感染和盆腔感染及腹腔感染等,后两种病种可根据情况单用本品或与其他抗菌药联合应用。此外有应用青霉素指征的患者,如患者对青霉素过敏或不宜用青霉素者本品可用作替代药物。

,敏感葡萄球菌属感染|链球菌属感染|肺炎链球菌感染|厌氧菌感染,盐酸林可霉素片的适应病症 91 | 硫酸特布他林片,

本品用于支气管哮喘,慢性支气管炎、肺气肿和其它伴有支气管痉挛的肺部疾病。

,支气管哮喘|慢性支气管炎|肺气肿|支气管痉挛,硫酸特布他林片的适应病症 92 | 福尔可定片,

本品用于剧烈干咳和中等度疼痛。

,剧烈干咳|中等度疼痛,福尔可定片的适应病症 93 | 益多酯片,

本品用于治疗高胆固醇血症。

,高胆固醇血症,益多酯片的适应病症 94 | 碘化钾片,

本品用于地方性甲状腺肿的预防与治疗,甲状腺功能亢进症手术前准备及甲状腺亢进危象。

,地方性甲状腺肿|甲状腺功能亢进症手术前准备|甲状腺亢进危象,碘化钾片的适应病症 95 | 那可丁片,

本品用于干咳。

,干咳,那可丁片的适应病症 96 | 保泰松片,

本品​用于治疗风湿性关节炎、类风湿性关节炎、强直性脊柱炎。本药大剂量可减少肾小管对尿酸盐的再吸收,促进尿酸盐排泄,故可用于治疗急性痛风。

,风湿性关节炎|类风湿性关节炎|强直性脊柱炎|急性痛风,保泰松片的适应病症 97 | 贝诺酯片,

本品适用于治疗普通感冒或流行性感冒引起的发热,也用于缓解轻至中度疼痛如头痛、关节痛、偏头痛、牙痛、肌肉痛、神经痛、痛经。

,头痛|关节痛|偏头痛|牙痛|肌肉痛|神经痛|痛经,贝诺酯片的适应病症 98 | 瑞格列奈片,

本品适用于饮食控制、减轻体重及运动锻炼不能有效控制其高血糖的2型糖尿病(非胰岛素依赖型)患者。当单独使用二甲双胍不能有效控制其高血糖时,瑞格列奈可与二甲双胍合用。治疗应从饮食控制和运动锻炼降低餐时血糖的辅助治疗开始。

,非胰岛素依赖型2型糖尿病,瑞格列奈片的适应病症 99 | 三磷酸腺苷二钠片,

本品适用于进行性肌萎缩、脑出血后遗症、心功能不全、心肌疾患及肝炎等的辅助治疗。

,进行性肌萎缩|脑出血后遗症|心功能不全|心肌疾患|肝炎,三磷酸腺苷二钠片的适应病症 100 | 沙利度胺片,

本品适用于控制瘤型麻风反应症。

,瘤型麻风反应症,沙利度胺片的适应病症 101 | 石杉碱甲片,

本品适用于良性记忆障碍,可提高患者指向记忆、联想学习、图像回忆、无意义图形再认及人像回忆等能力,对正常人的学习与记忆也有增强作用,对痴呆患者和脑器质性病变引起的记忆障碍亦有改善作用。

,良性记忆障碍|痴呆,石杉碱甲片的适应病症 102 | -------------------------------------------------------------------------------- /gradio_cama-demo.py: -------------------------------------------------------------------------------- 1 | from peft import PeftModel 2 | from transformers import LlamaForCausalLM, LlamaTokenizer, GenerationConfig 3 | import torch 4 | import sys 5 | import gradio as gr 6 | import argparse 7 | import os 8 | import mdtex2html 9 | from scripts.callbacks import Iteratorize, Stream 10 | # from examples.prompter import Prompter 11 | import transformers 12 | import os 13 | os.environ["CUDA_VISIBLE_DEVICES"] = '7' 14 | 15 | 16 | 17 | def postprocess(self, y): 18 | if y is None: 19 | return [] 20 | for i, (message, response) in enumerate(y): 21 | y[i] = ( 22 | None if message is None else mdtex2html.convert((message)), 23 | None if response is None else mdtex2html.convert(response), 24 | ) 25 | return y 26 | 27 | 28 | def reset_user_input(): 29 | return gr.update(value='') 30 | 31 | 32 | def reset_state(): 33 | return [], [] 34 | 35 | def generate_prompt(instruction): 36 | return f"""Below is an instruction that describes a task. Write a response that appropriately completes the request. 37 | 38 | ### Instruction: 39 | {instruction} 40 | 41 | ### Response: """ 42 | 43 | 44 | gr.Chatbot.postprocess = postprocess 45 | 46 | if torch.cuda.is_available(): 47 | device = "cuda" 48 | else: 49 | device = "cpu" 50 | 51 | try: 52 | if torch.backends.mps.is_available(): 53 | device = "mps" 54 | except: # noqa: E722 55 | pass 56 | 57 | base_model: str = "cama-path" 58 | lora_weights: str = "lora-path" 59 | load_8bit = False 60 | 61 | # prompter = Prompter(prompt_template) 62 | tokenizer = LlamaTokenizer.from_pretrained(base_model) 63 | if device == "cuda": 64 | model = LlamaForCausalLM.from_pretrained( 65 | base_model, 66 | load_in_8bit=load_8bit, 67 | torch_dtype=torch.float16, 68 | device_map="auto", 69 | ) 70 | model = PeftModel.from_pretrained( 71 | model, 72 | lora_weights, 73 | torch_dtype=torch.float16, 74 | ) 75 | elif device == "mps": 76 | model = LlamaForCausalLM.from_pretrained( 77 | base_model, 78 | device_map={"": device}, 79 | torch_dtype=torch.float16, 80 | ) 81 | model = PeftModel.from_pretrained( 82 | model, 83 | lora_weights, 84 | device_map={"": device}, 85 | torch_dtype=torch.float16, 86 | ) 87 | else: 88 | model = LlamaForCausalLM.from_pretrained( 89 | base_model, device_map={"": device}, low_cpu_mem_usage=True 90 | ) 91 | model = PeftModel.from_pretrained( 92 | model, 93 | lora_weights, 94 | device_map={"": device}, 95 | ) 96 | 97 | # unwind broken decapoda-research config 98 | model.config.pad_token_id = tokenizer.pad_token_id = 0 # pad 99 | model.config.bos_token_id = tokenizer.pad_token_id = 1 100 | model.config.eos_token_id = tokenizer.pad_token_id = 2 101 | 102 | if not load_8bit: 103 | model.half() # seems to fix bugs for some users. 104 | 105 | model.eval() 106 | if torch.__version__ >= "2" and sys.platform != "win32": 107 | model = torch.compile(model) 108 | 109 | 110 | max_memory=512 111 | 112 | def evaluate( 113 | chatbot, 114 | instruction, 115 | # input=None, 116 | temperature=0.4, 117 | top_p=0.75, 118 | top_k=40, 119 | num_beams=2, 120 | max_new_tokens=512, 121 | repetition_penalty=1.3, 122 | stream_output=False, 123 | history=None, 124 | **kwargs, 125 | ): 126 | 127 | now_input = instruction 128 | chatbot.append((instruction, "")) 129 | history = history or [] 130 | if len(history) != 0: 131 | instruction = "".join(["### Instruction:\n" + i[0] +"\n\n" + "### Response: " + i[1] + "\n\n" for i in history]) + \ 132 | "### Instruction:\n" + instruction 133 | instruction = instruction[len("### Instruction:\n"):] 134 | if len(instruction) > max_memory: 135 | instruction = instruction[-max_memory:] 136 | 137 | prompt = generate_prompt(instruction) 138 | inputs = tokenizer(prompt, return_tensors="pt") 139 | input_ids = inputs["input_ids"].to(device) 140 | generation_config = GenerationConfig( 141 | temperature=temperature, 142 | top_p=top_p, 143 | top_k=top_k, 144 | num_beams=num_beams, 145 | repetition_penalty=repetition_penalty, 146 | **kwargs, 147 | ) 148 | 149 | 150 | # Without streaming 151 | with torch.no_grad(): 152 | generation_output = model.generate( 153 | input_ids=input_ids, 154 | generation_config=generation_config, 155 | return_dict_in_generate=True, 156 | output_scores=True, 157 | max_new_tokens=max_new_tokens, 158 | ) 159 | s = generation_output.sequences[0] 160 | output = tokenizer.decode(s) 161 | # output = prompter.get_response(output) 162 | output = output.split("### Response:")[-1].strip() 163 | history.append((now_input, output)) 164 | chatbot[-1] = (now_input, output) 165 | # return chatbot, history 166 | # yield prompter.get_response(output) 167 | yield chatbot, history 168 | 169 | 170 | with gr.Blocks() as demo: 171 | gr.HTML("""

CaMA0601 - training - 3600steps

""") 172 | current_file_path = os.path.abspath(os.path.dirname(__file__)) 173 | # gr.Image(f'{current_file_path}/../pics/banner.png', label = 'Chinese LLaMA & Alpaca LLM') 174 | gr.Markdown("> 启真医学大模型") 175 | chatbot = gr.Chatbot() 176 | with gr.Row(): 177 | with gr.Column(scale=4): 178 | with gr.Column(scale=12): 179 | user_input = gr.Textbox(show_label=False, placeholder="Input...", lines=10).style( 180 | container=False) 181 | with gr.Column(min_width=32, scale=1): 182 | submitBtn = gr.Button("Submit", variant="primary") 183 | with gr.Column(scale=1): 184 | emptyBtn = gr.Button("Clear History") 185 | temperature = gr.components.Slider( 186 | minimum=0, maximum=1, value=0.4, label="Temperature" 187 | ) 188 | top_p = gr.components.Slider( 189 | minimum=0, maximum=1, value=0.75, label="Top p" 190 | ) 191 | top_k = gr.components.Slider( 192 | minimum=0, maximum=100, step=1, value=40, label="Top k" 193 | ) 194 | num_beams = gr.components.Slider( 195 | minimum=1, maximum=4, step=1, value=2, label="Beams" 196 | ) 197 | max_new_tokens = gr.components.Slider( 198 | minimum=1, maximum=2000, step=1, value=512, label="Max tokens" 199 | ) 200 | repetition_penalty = gr.components.Slider( 201 | minimum=1, maximum=2, step=0.1, value=1.3, label="Repetition Penalty" 202 | ) 203 | stream_output = gr.components.Checkbox(label="Stream output") 204 | 205 | history = gr.State([]) # (message, bot_message) 206 | 207 | submitBtn.click(evaluate, [chatbot, user_input, temperature, top_p, top_k, num_beams, max_new_tokens, repetition_penalty, stream_output, history],[chatbot, history], 208 | show_progress=True) 209 | # submitBtn.click(predict, [user_input, chatbot, history, max_length, top_p, temperature], [chatbot, history], 210 | # show_progress=True) 211 | submitBtn.click(reset_user_input, [], [user_input]) 212 | 213 | emptyBtn.click(reset_state, outputs=[chatbot, history], show_progress=True) 214 | 215 | demo.queue().launch(share=False, inbrowser=True, 216 | server_name='0.0.0.0', server_port=16666) 217 | -------------------------------------------------------------------------------- /gradio_chatglm_demo.py: -------------------------------------------------------------------------------- 1 | from transformers import AutoModel, AutoTokenizer 2 | import gradio as gr 3 | import mdtex2html 4 | from peft import PeftModel 5 | 6 | 7 | base_model_path = 'chatglm6b-path/' 8 | lora_model_path = 'lora-path/' 9 | 10 | tokenizer = AutoTokenizer.from_pretrained(base_model_path, trust_remote_code=True) 11 | base_model = AutoModel.from_pretrained(base_model_path, trust_remote_code=True).half().cuda() 12 | if lora_model_path is not None: 13 | print("loading peft model") 14 | model = PeftModel.from_pretrained(base_model, lora_model_path, torch_dtype='fp16', device_map='auto') 15 | else: 16 | model = base_model 17 | model = model.eval() 18 | 19 | """Override Chatbot.postprocess""" 20 | 21 | 22 | def postprocess(self, y): 23 | if y is None: 24 | return [] 25 | for i, (message, response) in enumerate(y): 26 | y[i] = ( 27 | None if message is None else mdtex2html.convert((message)), 28 | None if response is None else mdtex2html.convert(response), 29 | ) 30 | return y 31 | 32 | 33 | gr.Chatbot.postprocess = postprocess 34 | 35 | 36 | def parse_text(text): 37 | """copy from https://github.com/GaiZhenbiao/ChuanhuChatGPT/""" 38 | lines = text.split("\n") 39 | lines = [line for line in lines if line != ""] 40 | count = 0 41 | for i, line in enumerate(lines): 42 | if "```" in line: 43 | count += 1 44 | items = line.split('`') 45 | if count % 2 == 1: 46 | lines[i] = f'
'
 47 |             else:
 48 |                 lines[i] = f'
' 49 | else: 50 | if i > 0: 51 | if count % 2 == 1: 52 | line = line.replace("`", "\`") 53 | line = line.replace("<", "<") 54 | line = line.replace(">", ">") 55 | line = line.replace(" ", " ") 56 | line = line.replace("*", "*") 57 | line = line.replace("_", "_") 58 | line = line.replace("-", "-") 59 | line = line.replace(".", ".") 60 | line = line.replace("!", "!") 61 | line = line.replace("(", "(") 62 | line = line.replace(")", ")") 63 | line = line.replace("$", "$") 64 | lines[i] = "
"+line 65 | text = "".join(lines) 66 | return text 67 | 68 | 69 | def predict(input, chatbot, max_length, top_p, temperature, history): 70 | chatbot.append((parse_text(input), "")) 71 | for response, history in model.stream_chat(tokenizer, input, history, max_length=max_length, top_p=top_p, 72 | temperature=temperature,):#no_repeat_ngram_size=7 73 | chatbot[-1] = (parse_text(input), parse_text(response)) 74 | 75 | yield chatbot, history 76 | 77 | 78 | def reset_user_input(): 79 | return gr.update(value='') 80 | 81 | 82 | def reset_state(): 83 | return [], [] 84 | 85 | 86 | with gr.Blocks() as demo: 87 | gr.HTML("""

QiZhen-ChatGLM-6b

""") 88 | 89 | chatbot = gr.Chatbot() 90 | with gr.Row(): 91 | with gr.Column(scale=4): 92 | with gr.Column(scale=40): 93 | user_input = gr.Textbox(show_label=False, placeholder="Input...", lines=10).style( 94 | container=False) 95 | with gr.Column(min_width=32, scale=1): 96 | submitBtn = gr.Button("Submit", variant="primary") 97 | with gr.Column(scale=1): 98 | emptyBtn = gr.Button("Clear History") 99 | max_length = gr.Slider(0, 4096, value=512, step=1.0, label="Maximum length", interactive=True) 100 | top_p = gr.Slider(0, 1, value=0.85, step=0.01, label="Top P", interactive=True) 101 | temperature = gr.Slider(0, 1, value=0.95, step=0.01, label="Temperature", interactive=True) 102 | 103 | history = gr.State([]) 104 | 105 | submitBtn.click(predict, [user_input, chatbot, max_length, top_p, temperature, history], [chatbot, history], 106 | show_progress=True) 107 | submitBtn.click(reset_user_input, [], [user_input]) 108 | 109 | emptyBtn.click(reset_state, outputs=[chatbot, history], show_progress=True) 110 | 111 | demo.queue().launch(share=False, inbrowser=True, server_name = '0.0.0.0', server_port=16669) 112 | 113 | # nohup python web_demo.py > serve.out 2>&1 & 114 | -------------------------------------------------------------------------------- /gradio_chinese-llama_demo.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import gradio as gr 3 | import argparse 4 | import os 5 | import mdtex2html 6 | 7 | parser = argparse.ArgumentParser() 8 | parser.add_argument('--base_model', default="qizhen_model/", type=str) 9 | parser.add_argument('--tokenizer_path',default="qizhen_model/",type=str) 10 | parser.add_argument('--gpus', default="0", type=str) 11 | parser.add_argument('--only_cpu',action='store_true',help='only use CPU for inference') 12 | args = parser.parse_args() 13 | if args.only_cpu is True: 14 | args.gpus = "" 15 | os.environ["CUDA_VISIBLE_DEVICES"] = args.gpus 16 | 17 | import torch 18 | from transformers import LlamaForCausalLM, LlamaTokenizer, GenerationConfig 19 | from peft import PeftModel 20 | 21 | def postprocess(self, y): 22 | if y is None: 23 | return [] 24 | for i, (message, response) in enumerate(y): 25 | y[i] = ( 26 | None if message is None else mdtex2html.convert((message)), 27 | None if response is None else mdtex2html.convert(response), 28 | ) 29 | return y 30 | 31 | 32 | gr.Chatbot.postprocess = postprocess 33 | 34 | 35 | load_type = torch.float16 36 | if torch.cuda.is_available(): 37 | device = torch.device(0) 38 | else: 39 | device = torch.device('cpu') 40 | if args.tokenizer_path is None: 41 | args.tokenizer_path = args.lora_model 42 | if args.lora_model is None: 43 | args.tokenizer_path = args.base_model 44 | tokenizer = LlamaTokenizer.from_pretrained(args.tokenizer_path) 45 | 46 | base_model = LlamaForCausalLM.from_pretrained( 47 | args.base_model, 48 | load_in_8bit=False, 49 | torch_dtype=load_type, 50 | low_cpu_mem_usage=True, 51 | device_map='auto', 52 | ) 53 | 54 | model_vocab_size = base_model.get_input_embeddings().weight.size(0) 55 | tokenzier_vocab_size = len(tokenizer) 56 | print(f"Vocab of the base model: {model_vocab_size}") 57 | print(f"Vocab of the tokenizer: {tokenzier_vocab_size}") 58 | if model_vocab_size!=tokenzier_vocab_size: 59 | assert tokenzier_vocab_size > model_vocab_size 60 | print("Resize model embeddings to fit tokenizer") 61 | base_model.resize_token_embeddings(tokenzier_vocab_size) 62 | 63 | model = base_model 64 | 65 | if device==torch.device('cpu'): 66 | model.float() 67 | 68 | model.eval() 69 | 70 | def reset_user_input(): 71 | return gr.update(value='') 72 | 73 | def reset_state(): 74 | return [], [] 75 | 76 | def generate_prompt(instruction): 77 | return f"""Below is an instruction that describes a task. Write a response that appropriately completes the request. 78 | 79 | ### Instruction: 80 | {instruction} 81 | 82 | ### Response: """ 83 | 84 | if torch.__version__ >= "2" and sys.platform != "win32": 85 | model = torch.compile(model) 86 | 87 | def predict( 88 | input, 89 | chatbot, 90 | history, 91 | max_new_tokens=512, 92 | top_p=0.9, 93 | temperature=0.1, 94 | top_k=40, 95 | num_beams=4, 96 | repetition_penalty=1.0, 97 | max_memory=256, 98 | **kwargs, 99 | ): 100 | now_input = input 101 | chatbot.append((input, "")) 102 | history = history or [] 103 | if len(history) != 0: 104 | input = "".join(["### Instruction:\n" + i[0] +"\n\n" + "### Response: " + i[1] + "\n\n" for i in history]) + \ 105 | "### Instruction:\n" + input 106 | input = input[len("### Instruction:\n"):] 107 | if len(input) > max_memory: 108 | input = input[-max_memory:] 109 | prompt = generate_prompt(input) 110 | inputs = tokenizer(prompt, return_tensors="pt") 111 | input_ids = inputs["input_ids"].to(device) 112 | generation_config = GenerationConfig( 113 | temperature=temperature, 114 | top_p=top_p, 115 | top_k=top_k, 116 | num_beams=num_beams, 117 | **kwargs, 118 | ) 119 | with torch.no_grad(): 120 | generation_output = model.generate( 121 | input_ids=input_ids, 122 | generation_config=generation_config, 123 | return_dict_in_generate=True, 124 | output_scores=False, 125 | max_new_tokens=max_new_tokens, 126 | repetition_penalty=float(repetition_penalty), 127 | ) 128 | s = generation_output.sequences[0] 129 | output = tokenizer.decode(s, skip_special_tokens=True) 130 | output = output.split("### Response:")[-1].strip() 131 | history.append((now_input, output)) 132 | chatbot[-1] = (now_input, output) 133 | return chatbot, history 134 | 135 | with gr.Blocks() as demo: 136 | gr.HTML("""

启真医学大模型

""") 137 | current_file_path = os.path.abspath(os.path.dirname(__file__)) 138 | chatbot = gr.Chatbot() 139 | with gr.Row(): 140 | with gr.Column(scale=4): 141 | with gr.Column(scale=12): 142 | user_input = gr.Textbox(show_label=False, placeholder="Input...", lines=10).style( 143 | container=False) 144 | with gr.Column(min_width=32, scale=1): 145 | submitBtn = gr.Button("Submit", variant="primary") 146 | with gr.Column(scale=1): 147 | emptyBtn = gr.Button("Clear History") 148 | max_length = gr.Slider( 149 | 0, 4096, value=512, step=1.0, label="Maximum length", interactive=True) 150 | top_p = gr.Slider(0, 1, value=0.9, step=0.01, 151 | label="Top P", interactive=True) 152 | temperature = gr.Slider( 153 | 0, 1, value=0.1, step=0.01, label="Temperature", interactive=True) 154 | 155 | history = gr.State([]) # (message, bot_message) 156 | 157 | submitBtn.click(predict, [user_input, chatbot, history, max_length, top_p, temperature], [chatbot, history], 158 | show_progress=True) 159 | submitBtn.click(reset_user_input, [], [user_input]) 160 | 161 | emptyBtn.click(reset_state, outputs=[chatbot, history], show_progress=True) 162 | demo.queue().launch(share=False, inbrowser=True, server_name = '0.0.0.0', server_port=16667) -------------------------------------------------------------------------------- /lora/lora_weights: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMKRG/QiZhenGPT/cf5be4d33d7fda3813e0e19623f81056d07fce2f/lora/lora_weights -------------------------------------------------------------------------------- /pics/llm_kg1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMKRG/QiZhenGPT/cf5be4d33d7fda3813e0e19623f81056d07fce2f/pics/llm_kg1.jpg -------------------------------------------------------------------------------- /pics/llm_kg2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMKRG/QiZhenGPT/cf5be4d33d7fda3813e0e19623f81056d07fce2f/pics/llm_kg2.jpg -------------------------------------------------------------------------------- /pics/medcopilot1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CMKRG/QiZhenGPT/cf5be4d33d7fda3813e0e19623f81056d07fce2f/pics/medcopilot1.jpg -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | accelerate==0.19.0 2 | aiofiles==23.1.0 3 | aiohttp==3.8.4 4 | aiosignal==1.3.1 5 | altair==5.0.0 6 | anyio==3.6.2 7 | async-timeout==4.0.2 8 | attrs==23.1.0 9 | brotlipy==0.7.0 10 | certifi==2023.5.7 11 | cffi==1.15.1 12 | charset-normalizer==2.0.4 13 | click==8.1.3 14 | contourpy==1.0.7 15 | cryptography==39.0.1 16 | cycler==0.11.0 17 | datasets==2.12.0 18 | deepspeed==0.9.2 19 | dill==0.3.6 20 | fastapi==0.95.2 21 | ffmpy==0.3.0 22 | filelock==3.12.0 23 | fonttools==4.39.4 24 | frozenlist==1.3.3 25 | fsspec==2023.5.0 26 | gmpy2==2.1.2 27 | gradio==3.31.0 28 | gradio_client==0.2.5 29 | h11==0.14.0 30 | hjson==3.1.0 31 | httpcore==0.17.1 32 | httpx==0.24.1 33 | huggingface-hub==0.14.1 34 | idna==3.4 35 | Jinja2==3.1.2 36 | jsonschema==4.17.3 37 | kiwisolver==1.4.4 38 | latex2mathml==3.75.5 39 | linkify-it-py==2.0.2 40 | Markdown==3.4.3 41 | markdown-it-py==2.2.0 42 | MarkupSafe==2.1.1 43 | matplotlib==3.7.1 44 | mdit-py-plugins==0.3.3 45 | mdtex2html==1.2.0 46 | mdurl==0.1.2 47 | mkl-fft==1.3.6 48 | mkl-random==1.2.2 49 | mkl-service==2.4.0 50 | mpmath==1.2.1 51 | multidict==6.0.4 52 | multiprocess==0.70.14 53 | networkx==2.8.4 54 | ninja==1.11.1 55 | numpy==1.24.3 56 | orjson==3.8.12 57 | packaging==23.1 58 | pandas==2.0.1 59 | peft==0.3.0.dev0 60 | Pillow==9.4.0 61 | pip==23.0.1 62 | psutil==5.9.5 63 | py-cpuinfo==9.0.0 64 | pyarrow==12.0.0 65 | pycparser==2.21 66 | pydantic==1.10.7 67 | pydub==0.25.1 68 | Pygments==2.15.1 69 | pyOpenSSL==23.0.0 70 | pyparsing==3.0.9 71 | pyrsistent==0.19.3 72 | PySocks==1.7.1 73 | python-dateutil==2.8.2 74 | python-multipart==0.0.6 75 | pytz==2023.3 76 | PyYAML==6.0 77 | regex==2023.5.5 78 | requests==2.29.0 79 | responses==0.18.0 80 | semantic-version==2.10.0 81 | sentencepiece==0.1.97 82 | setuptools==66.0.0 83 | six==1.16.0 84 | sniffio==1.3.0 85 | starlette==0.27.0 86 | sympy==1.11.1 87 | tokenizers==0.13.3 88 | toolz==0.12.0 89 | torch==1.13.1 90 | torchaudio==0.13.1 91 | torchvision==0.14.1 92 | tqdm==4.65.0 93 | transformers==4.28.1 94 | triton==2.0.0 95 | typing_extensions==4.5.0 96 | tzdata==2023.3 97 | uc-micro-py==1.0.2 98 | urllib3==1.26.15 99 | uvicorn==0.22.0 100 | websockets==11.0.3 101 | wheel==0.38.4 102 | xxhash==3.2.0 103 | yarl==1.9.2 104 | -------------------------------------------------------------------------------- /scripts/callbacks.py: -------------------------------------------------------------------------------- 1 | """ 2 | Helpers to support streaming generate output. 3 | Borrowed from https://github.com/oobabooga/text-generation-webui/blob/ad37f396fc8bcbab90e11ecf17c56c97bfbd4a9c/modules/callbacks.py 4 | """ 5 | 6 | import gc 7 | import traceback 8 | from queue import Queue 9 | from threading import Thread 10 | 11 | import torch 12 | import transformers 13 | 14 | 15 | class Stream(transformers.StoppingCriteria): 16 | def __init__(self, callback_func=None): 17 | self.callback_func = callback_func 18 | 19 | def __call__(self, input_ids, scores) -> bool: 20 | if self.callback_func is not None: 21 | self.callback_func(input_ids[0]) 22 | return False 23 | 24 | 25 | class Iteratorize: 26 | 27 | """ 28 | Transforms a function that takes a callback 29 | into a lazy iterator (generator). 30 | """ 31 | 32 | def __init__(self, func, kwargs={}, callback=None): 33 | self.mfunc = func 34 | self.c_callback = callback 35 | self.q = Queue() 36 | self.sentinel = object() 37 | self.kwargs = kwargs 38 | self.stop_now = False 39 | 40 | def _callback(val): 41 | if self.stop_now: 42 | raise ValueError 43 | self.q.put(val) 44 | 45 | def gentask(): 46 | try: 47 | ret = self.mfunc(callback=_callback, **self.kwargs) 48 | except ValueError: 49 | pass 50 | except: 51 | traceback.print_exc() 52 | pass 53 | 54 | self.q.put(self.sentinel) 55 | if self.c_callback: 56 | self.c_callback(ret) 57 | 58 | self.thread = Thread(target=gentask) 59 | self.thread.start() 60 | 61 | def __iter__(self): 62 | return self 63 | 64 | def __next__(self): 65 | obj = self.q.get(True, None) 66 | if obj is self.sentinel: 67 | raise StopIteration 68 | else: 69 | return obj 70 | 71 | def __enter__(self): 72 | return self 73 | 74 | def __exit__(self, exc_type, exc_val, exc_tb): 75 | self.stop_now = True 76 | -------------------------------------------------------------------------------- /scripts/merge_llama_plus.sh: -------------------------------------------------------------------------------- 1 | python scripts/merge_llama_with_chinese_lora.py \ 2 | --base_model Chinese-LLaMA-Plus-path \ 3 | --lora_model lora/checkpoint-3500 \ 4 | --output_type huggingface \ 5 | --output_dir qizhen_model/ -------------------------------------------------------------------------------- /scripts/merge_llama_with_chinese_lora.py: -------------------------------------------------------------------------------- 1 | """ 2 | Usage: 3 | python merge_llama_with_chinese_lora.py \ 4 | --base_model path/to/llama/model \ 5 | --lora_model path/to/first/lora/model [path/to/second/lora/model] \ 6 | --output_type [pth|huggingface] \ 7 | --output_dir path/to/output/dir 8 | """ 9 | import argparse 10 | import json 11 | import os 12 | import gc 13 | import torch 14 | import peft 15 | from peft import PeftModel 16 | from transformers import LlamaForCausalLM, LlamaTokenizer 17 | from huggingface_hub import hf_hub_download 18 | 19 | parser = argparse.ArgumentParser() 20 | parser.add_argument('--base_model', default=None, required=True, 21 | type=str, help="Please specify a base_model") 22 | parser.add_argument('--lora_model', default=None, required=True, 23 | type=str, help="Please specify LoRA models to be merged (ordered); use commas to separate multiple LoRA models.") 24 | parser.add_argument('--offload_dir', default=None, type=str, 25 | help="(Optional) Please specify a temp folder for offloading (useful for low-RAM machines). Default None (disable offload).") 26 | parser.add_argument('--output_type', default='pth',choices=['pth','huggingface'], type=str, 27 | help="save the merged model in pth or huggingface format.") 28 | parser.add_argument('--output_dir', default='./', type=str) 29 | 30 | 31 | emb_to_model_size = { 32 | 4096 : '7B', 33 | 5120 : '13B', 34 | 6656 : '30B', 35 | 8192 : '65B', 36 | } 37 | num_shards_of_models = {'7B': 1, '13B': 2} 38 | params_of_models = { 39 | '7B': 40 | { 41 | "dim": 4096, 42 | "multiple_of": 256, 43 | "n_heads": 32, 44 | "n_layers": 32, 45 | "norm_eps": 1e-06, 46 | "vocab_size": -1, 47 | }, 48 | '13B': 49 | { 50 | "dim": 5120, 51 | "multiple_of": 256, 52 | "n_heads": 40, 53 | "n_layers": 40, 54 | "norm_eps": 1e-06, 55 | "vocab_size": -1, 56 | }, 57 | } 58 | 59 | def transpose(weight, fan_in_fan_out): 60 | return weight.T if fan_in_fan_out else weight 61 | 62 | # Borrowed and modified from https://github.com/tloen/alpaca-lora 63 | def translate_state_dict_key(k): 64 | k = k.replace("base_model.model.", "") 65 | if k == "model.embed_tokens.weight": 66 | return "tok_embeddings.weight" 67 | elif k == "model.norm.weight": 68 | return "norm.weight" 69 | elif k == "lm_head.weight": 70 | return "output.weight" 71 | elif k.startswith("model.layers."): 72 | layer = k.split(".")[2] 73 | if k.endswith(".self_attn.q_proj.weight"): 74 | return f"layers.{layer}.attention.wq.weight" 75 | elif k.endswith(".self_attn.k_proj.weight"): 76 | return f"layers.{layer}.attention.wk.weight" 77 | elif k.endswith(".self_attn.v_proj.weight"): 78 | return f"layers.{layer}.attention.wv.weight" 79 | elif k.endswith(".self_attn.o_proj.weight"): 80 | return f"layers.{layer}.attention.wo.weight" 81 | elif k.endswith(".mlp.gate_proj.weight"): 82 | return f"layers.{layer}.feed_forward.w1.weight" 83 | elif k.endswith(".mlp.down_proj.weight"): 84 | return f"layers.{layer}.feed_forward.w2.weight" 85 | elif k.endswith(".mlp.up_proj.weight"): 86 | return f"layers.{layer}.feed_forward.w3.weight" 87 | elif k.endswith(".input_layernorm.weight"): 88 | return f"layers.{layer}.attention_norm.weight" 89 | elif k.endswith(".post_attention_layernorm.weight"): 90 | return f"layers.{layer}.ffn_norm.weight" 91 | elif k.endswith("rotary_emb.inv_freq") or "lora" in k: 92 | return None 93 | else: 94 | print(layer, k) 95 | raise NotImplementedError 96 | else: 97 | print(k) 98 | raise NotImplementedError 99 | 100 | 101 | def unpermute(w): 102 | return ( 103 | w.view(n_heads, 2, dim // n_heads // 2, dim).transpose(1, 2).reshape(dim, dim) 104 | ) 105 | 106 | 107 | def save_shards(model_sd, num_shards: int): 108 | # Add the no_grad context manager 109 | with torch.no_grad(): 110 | if num_shards == 1: 111 | new_state_dict = {} 112 | for k, v in model_sd.items(): 113 | new_k = translate_state_dict_key(k) 114 | if new_k is not None: 115 | if "wq" in new_k or "wk" in new_k: 116 | new_state_dict[new_k] = unpermute(v) 117 | else: 118 | new_state_dict[new_k] = v 119 | 120 | os.makedirs(output_dir, exist_ok=True) 121 | print(f"Saving shard 1 of {num_shards} into {output_dir}/consolidated.00.pth") 122 | torch.save(new_state_dict, output_dir + "/consolidated.00.pth") 123 | with open(output_dir + "/params.json", "w") as f: 124 | json.dump(params, f) 125 | else: 126 | new_state_dicts = [dict() for _ in range(num_shards)] 127 | for k in list(model_sd.keys()): 128 | v = model_sd[k] 129 | new_k = translate_state_dict_key(k) 130 | if new_k is not None: 131 | if new_k=='tok_embeddings.weight': 132 | print(f"Processing {new_k}") 133 | assert v.size(1)%num_shards==0 134 | splits = v.split(v.size(1)//num_shards,dim=1) 135 | elif new_k=='output.weight': 136 | print(f"Processing {new_k}") 137 | if v.size(0)%num_shards==0: 138 | splits = v.split(v.size(0)//num_shards,dim=0) 139 | else: 140 | size_list = [v.size(0)//num_shards] * num_shards 141 | size_list[-1] += v.size(0)%num_shards 142 | splits = v.split(size_list, dim=0) # 13B: size_list == [24976,24977] 143 | elif new_k=='norm.weight': 144 | print(f"Processing {new_k}") 145 | splits = [v] * num_shards 146 | elif 'ffn_norm.weight' in new_k: 147 | print(f"Processing {new_k}") 148 | splits = [v] * num_shards 149 | elif 'attention_norm.weight' in new_k: 150 | print(f"Processing {new_k}") 151 | splits = [v] * num_shards 152 | 153 | 154 | elif 'w1.weight' in new_k: 155 | print(f"Processing {new_k}") 156 | splits = v.split(v.size(0)//num_shards,dim=0) 157 | elif 'w2.weight' in new_k: 158 | print(f"Processing {new_k}") 159 | splits = v.split(v.size(1)//num_shards,dim=1) 160 | elif 'w3.weight' in new_k: 161 | print(f"Processing {new_k}") 162 | splits = v.split(v.size(0)//num_shards,dim=0) 163 | 164 | 165 | elif 'wo.weight' in new_k: 166 | print(f"Processing {new_k}") 167 | splits = v.split(v.size(1)//num_shards,dim=1) 168 | 169 | elif 'wv.weight' in new_k: 170 | print(f"Processing {new_k}") 171 | splits = v.split(v.size(0)//num_shards,dim=0) 172 | 173 | elif "wq.weight" in new_k or "wk.weight" in new_k: 174 | print(f"Processing {new_k}") 175 | v = unpermute(v) 176 | splits = v.split(v.size(0)//num_shards,dim=0) 177 | else: 178 | print(f"Unexpected key {new_k}") 179 | raise ValueError 180 | for sd,split in zip(new_state_dicts,splits): 181 | sd[new_k] = split.clone() 182 | del split 183 | del splits 184 | del model_sd[k],v 185 | gc.collect() # Effectively enforce garbage collection 186 | 187 | os.makedirs(output_dir, exist_ok=True) 188 | for i,new_state_dict in enumerate(new_state_dicts): 189 | print(f"Saving shard {i+1} of {num_shards} into {output_dir}/consolidated.0{i}.pth") 190 | torch.save(new_state_dict, output_dir + f"/consolidated.0{i}.pth") 191 | with open(output_dir + "/params.json", "w") as f: 192 | print(f"Saving params.json into {output_dir}/params.json") 193 | json.dump(params, f) 194 | 195 | 196 | if __name__=='__main__': 197 | 198 | args = parser.parse_args() 199 | base_model_path = args.base_model 200 | lora_model_paths = [s.strip() for s in args.lora_model.split(',') if len(s.strip())!=0] 201 | output_dir = args.output_dir 202 | output_type = args.output_type 203 | offload_dir = args.offload_dir 204 | 205 | print(f"Base model: {base_model_path}") 206 | print(f"LoRA model(s) {lora_model_paths}:") 207 | 208 | if offload_dir is not None: 209 | # Load with offloading, which is useful for low-RAM machines. 210 | # Note that if you have enough RAM, please use original method instead, as it is faster. 211 | base_model = LlamaForCausalLM.from_pretrained( 212 | base_model_path, 213 | load_in_8bit=False, 214 | torch_dtype=torch.float16, 215 | offload_folder=offload_dir, 216 | offload_state_dict=True, 217 | low_cpu_mem_usage=True, 218 | device_map={"": "cpu"}, 219 | ) 220 | else: 221 | # Original method without offloading 222 | base_model = LlamaForCausalLM.from_pretrained( 223 | base_model_path, 224 | load_in_8bit=False, 225 | torch_dtype=torch.float16, 226 | device_map={"": "cpu"}, 227 | ) 228 | 229 | ## infer the model size from the checkpoint 230 | embedding_size = base_model.get_input_embeddings().weight.size(1) 231 | model_size = emb_to_model_size[embedding_size] 232 | print(f"Peft version: {peft.__version__}") 233 | print(f"Loading LoRA for {model_size} model") 234 | 235 | lora_model = None 236 | lora_model_sd = None 237 | for lora_index, lora_model_path in enumerate(lora_model_paths): 238 | print(f"Loading LoRA {lora_model_path}") 239 | tokenizer = LlamaTokenizer.from_pretrained(lora_model_path) 240 | if base_model.get_input_embeddings().weight.size(0) != len(tokenizer): 241 | base_model.resize_token_embeddings(len(tokenizer)) 242 | print(f"Extended vocabulary size to {len(tokenizer)}") 243 | 244 | first_weight = base_model.model.layers[0].self_attn.q_proj.weight 245 | first_weight_old = first_weight.clone() 246 | 247 | if hasattr(peft.LoraModel,'merge_and_unload'): 248 | lora_model = PeftModel.from_pretrained( 249 | base_model, 250 | lora_model_path, 251 | device_map={"": "cpu"}, 252 | torch_dtype=torch.float16, 253 | ) 254 | assert torch.allclose(first_weight_old, first_weight) 255 | print(f"Merging with merge_and_unload...") 256 | base_model = lora_model.merge_and_unload() 257 | else: 258 | base_model_sd = base_model.state_dict() 259 | try: 260 | lora_model_sd = torch.load(os.path.join(lora_model_path,'adapter_model.bin'),map_location='cpu') 261 | except FileNotFoundError: 262 | print("Cannot find lora model on the disk. Downloading lora model from hub...") 263 | filename = hf_hub_download(repo_id=lora_model_path,filename='adapter_model.bin') 264 | lora_model_sd = torch.load(filename,map_location='cpu') 265 | 266 | lora_config = peft.LoraConfig.from_pretrained(lora_model_path) 267 | lora_scaling = lora_config.lora_alpha / lora_config.r 268 | fan_in_fan_out = lora_config.fan_in_fan_out 269 | lora_keys = [k for k in lora_model_sd if 'lora_A' in k] 270 | non_lora_keys = [k for k in lora_model_sd if not 'lora_' in k] 271 | 272 | for k in non_lora_keys: 273 | print(f"merging {k}") 274 | original_k = k.replace('base_model.model.','') 275 | base_model_sd[original_k].copy_(lora_model_sd[k]) 276 | 277 | for k in lora_keys: 278 | print(f"merging {k}") 279 | original_key = k.replace('.lora_A','').replace('base_model.model.','') 280 | assert original_key in base_model_sd 281 | lora_a_key = k 282 | lora_b_key = k.replace('lora_A','lora_B') 283 | base_model_sd[original_key] += ( 284 | transpose(lora_model_sd[lora_b_key].float() @ lora_model_sd[lora_a_key].float(),fan_in_fan_out) * lora_scaling 285 | ) 286 | assert base_model_sd[original_key].dtype == torch.float16 287 | 288 | # did we do anything? 289 | assert not torch.allclose(first_weight_old, first_weight) 290 | 291 | tokenizer.save_pretrained(output_dir) 292 | 293 | if output_type=='huggingface': 294 | print("Saving to Hugging Face format...") 295 | LlamaForCausalLM.save_pretrained(base_model, output_dir) #, state_dict=deloreanized_sd) 296 | else: # output_type=='pth 297 | print("Saving to pth format...") 298 | 299 | base_model_sd = base_model.state_dict() 300 | del lora_model, base_model, lora_model_sd 301 | 302 | params = params_of_models[model_size] 303 | num_shards = num_shards_of_models[model_size] 304 | n_layers = params["n_layers"] 305 | n_heads = params["n_heads"] 306 | dim = params["dim"] 307 | dims_per_head = dim // n_heads 308 | base = 10000.0 309 | inv_freq = 1.0 / (base ** (torch.arange(0, dims_per_head, 2).float() / dims_per_head)) 310 | 311 | save_shards(model_sd=base_model_sd, num_shards=num_shards) 312 | --------------------------------------------------------------------------------