使用大型语言模(LLM)构建系统(七):评估1

news2025/5/17 12:23:41

今天我学习了DeepLearning.AI的 Building Systems with LLM 的在线课程,我想和大家一起分享一下该门课程的一些主要内容。之前我们已经学习了下面这些知识:

  1. 使用大型语言模(LLM)构建系统(一):分类
  2. 使用大型语言模(LLM)构建系统(二):内容审核、预防Prompt注入
  3. 使用大型语言模(LLM)构建系统(三):思维链推理
  4. 使用大型语言模(LLM)构建系统(四):链式提示
  5. 使用大型语言模(LLM)构建系统(五):输出结果检查
  6. 使用大型语言模(LLM)构建系统(六):构建端到端系统

在之前的博客,我们已经完成了大型语言模(LLM)构建端到端系统,在系统开发完成后,我们需要对系统功能进行评估,所谓评估是指我们需要设计一下测试用例来对系统功能进行测试,并观察测试结果是否符合要求。这里我们要测试的系统是在上一篇博客中开发的端到端系统。 下面是我们访问LLM模型的主要代码,这里我加入了backoff包,它的功能主要是为了防止API调用时出现Rate limit错误,报错的原因我在之前的博客中已经说明,这里不在赘述。:

import openai
import backoff 
 
#您的openai的api key
openai.api_key ='YOUR-OPENAI-API-KEY' 

@backoff.on_exception(backoff.expo, openai.error.RateLimitError) 
def get_completion_from_messages(messages, 
                                 model="gpt-3.5-turbo", 
                                 temperature=0, 
                                 max_tokens=500):
    response = openai.ChatCompletion.create(
        model=model,
        messages=messages,
        temperature=temperature, 
        max_tokens=max_tokens,
    )
    return response.choices[0].message["content"]

获取相关的产品和类别

在上一篇博客中我们开了一个端到端的系统,该系统的主要功能开发一个个性化的客服机器人来回答用户对相关电子产品的问题,当用户提出问题时,系统首先需要识别用户问题中提到的电子产品是否包含在系统中的电子产品目前清单中,下面的代码是查看目前系统中所有的电子产品目前清单:

products_and_category = utils.get_products_and_category()
products_and_category

下面我们看一下产品目前清单中的所有类别,目前在产品目前清单中一个有6个类别:

#所有类别
list(products_and_category.keys())

这里看到我们的电子产品包含了6个大类,在每个大类下面都有若干个具体的电子产品,我们会用一个python字典来存储产品目录清单,其中key对应的是类别,value对应的是具体的产品。

查找相关的产品和类别名称(版本1)

下面我们要定义一个查找相关产品和分类的名称的函数,该函数接收客户的问题,并返回和问题相关的产品和分类的目录清单:

def find_category_and_product_v1(user_input,products_and_category):

    delimiter = "####"
    system_message = f"""
    You will be provided with customer service queries. \
    The customer service query will be delimited with {delimiter} characters.
    Output a python list of json objects, where each object has the following format:
        'category': <one of Computers and Laptops, Smartphones and Accessories, Televisions and Home Theater Systems, \
    Gaming Consoles and Accessories, Audio Equipment, Cameras and Camcorders>,
    AND
        'products': <a list of products that must be found in the allowed products below>


    Where the categories and products must be found in the customer service query.
    If a product is mentioned, it must be associated with the correct category in the allowed products list below.
    If no products or categories are found, output an empty list.
    

    List out all products that are relevant to the customer service query based on how closely it relates
    to the product name and product category.
    Do not assume, from the name of the product, any features or attributes such as relative quality or price.

    The allowed products are provided in JSON format.
    The keys of each item represent the category.
    The values of each item is a list of products that are within that category.
    Allowed products: {products_and_category}
    

    """
    
    few_shot_user_1 = """I want the most expensive computer."""
    few_shot_assistant_1 = """ 
    [{'category': 'Computers and Laptops', \
'products': ['TechPro Ultrabook', 'BlueWave Gaming Laptop', 'PowerLite Convertible', 'TechPro Desktop', 'BlueWave Chromebook']}]
    """
    
    messages =  [  
    {'role':'system', 'content': system_message},    
    {'role':'user', 'content': f"{delimiter}{few_shot_user_1}{delimiter}"},  
    {'role':'assistant', 'content': few_shot_assistant_1 },
    {'role':'user', 'content': f"{delimiter}{user_input}{delimiter}"},  
    ] 
    return get_completion_from_messages(messages)

这里我们将system_message翻译成中文,这样便于大家理解:

System_message = f"""
您将获得客户服务查询。
客户服务查询将用{delimiter}字符分隔。
输出json对象的python列表,其中每个对象具有以下格式:
“category”:<电脑和笔记本电脑,智能手机和配件,电视和家庭影院系统之一,
游戏机及配件、音响设备、照相机及摄像机>、
和
'products': <必须在下面允许的产品中找到的产品列表>


其中类别和产品必须在客户服务查询中找到。
如果提到某个产品,它必须与下面允许的产品列表中的正确类别相关联。
如果没有找到任何产品或类别,则输出一个空列表。


列出与客户服务查询相关的所有产品
到产品名称和产品类别。
不要从产品的名称中假设任何特征或属性,例如相对质量或价格。

允许的产品以JSON格式提供。
每个项目的键代表类别。
每个项目的值是属于该类别的产品列表。
允许的产品:{products_and_category}
"""

在这里我们除了提供system_message以外,我们还提供了一对自问自答的少量学习样本few_shot_user_1和few_shot_assistant_1 ,这样做的目的是训练LLM让它知道如何正确的按指定格式来输出查询结果。

评估 find_category_and_product_v1

定义好了find_category_and_product_v1方法,下面我们设计几个用户的问题来评估一下find_category_and_product_v1的实际效果。

customer_msg_0 = f"""Which TV can I buy if I'm on a budget?"""

products_by_category_0 = find_category_and_product_v1(customer_msg_0,
                                                      products_and_category)
print(products_by_category_0)

customer_msg_1 = f"""I need a charger for my smartphone"""

products_by_category_1 = find_category_and_product_v1(customer_msg_1,
                                                      products_and_category)
products_by_category_1

customer_msg_2 = f"""What computers do you have?"""
products_by_category_2 = find_category_and_product_v1(customer_msg_2,
                                                      products_and_category)
products_by_category_2

customer_msg_3 = f"""
tell me about the smartx pro phone and the fotosnap camera, the dslr one.
Also, what TVs do you have?"""

products_by_category_3 = find_category_and_product_v1(customer_msg_3,
                                                      products_and_category)
print(products_by_category_3)

 这里的4个用户问题,LLM都按指定的格式输出了查询结果,注意,这里的查询结果都是以字符串的形式输出。

更复杂的测试用例

 下面我们需要设计更为复杂一点的测试用例看看find_category_and_product_v1还能否按要求来输出结果。

customer_msg_4 = f"""
tell me about the CineView TV, the 8K one, Gamesphere console, the X one.
I'm on a budget, what computers do you have?"""

products_by_category_4 = find_category_and_product_v1(customer_msg_4,
                                                      products_and_category)
print(products_by_category_4)

 

 从上面的输出结果可以看到当客户的问题稍微复杂一点的时候,LLM输出的结果中除了我们要求的指定格式的信息以外,还有一部分文本信息,但是这部分文本信息是我们不需要的,因为我们的系统需要需要把输出结果转换成指定的python的List格式,如果输出结果中混有文本信息就无法进行格式转换。

修改prompt(提示语)以处理更复杂的测试用例(版本2)

下面我们需要修改system_message,以便让它可以处理类似之前那种复杂的用户问题。主要的目的是防止LLM输出不必要的文本信息。

def find_category_and_product_v2(user_input,products_and_category):
    """
    Added: Do not output any additional text that is not in JSON format.
    Added a second example (for few-shot prompting) where user asks for 
    the cheapest computer. In both few-shot examples, the shown response 
    is the full list of products in JSON only.
    """
    delimiter = "####"
    system_message = f"""
    You will be provided with customer service queries. \
    The customer service query will be delimited with {delimiter} characters.
    Output a python list of json objects, where each object has the following format:
        'category': <one of Computers and Laptops, Smartphones and Accessories, Televisions and Home Theater Systems, \
    Gaming Consoles and Accessories, Audio Equipment, Cameras and Camcorders>,
    AND
        'products': <a list of products that must be found in the allowed products below>
    Do not output any additional text that is not in JSON format.
    Do not write any explanatory text after outputting the requested JSON.


    Where the categories and products must be found in the customer service query.
    If a product is mentioned, it must be associated with the correct category in the allowed products list below.
    If no products or categories are found, output an empty list.
    

    List out all products that are relevant to the customer service query based on how closely it relates
    to the product name and product category.
    Do not assume, from the name of the product, any features or attributes such as relative quality or price.

    The allowed products are provided in JSON format.
    The keys of each item represent the category.
    The values of each item is a list of products that are within that category.
    Allowed products: {products_and_category}
    

    """
    
    few_shot_user_1 = """I want the most expensive computer. What do you recommend?"""
    few_shot_assistant_1 = """ 
    [{'category': 'Computers and Laptops', \
'products': ['TechPro Ultrabook', 'BlueWave Gaming Laptop', 'PowerLite Convertible', 'TechPro Desktop', 'BlueWave Chromebook']}]
    """
    
    few_shot_user_2 = """I want the most cheapest computer. What do you recommend?"""
    few_shot_assistant_2 = """ 
    [{'category': 'Computers and Laptops', \
'products': ['TechPro Ultrabook', 'BlueWave Gaming Laptop', 'PowerLite Convertible', 'TechPro Desktop', 'BlueWave Chromebook']}]
    """
    
    messages =  [  
    {'role':'system', 'content': system_message},    
    {'role':'user', 'content': f"{delimiter}{few_shot_user_1}{delimiter}"},  
    {'role':'assistant', 'content': few_shot_assistant_1 },
    {'role':'user', 'content': f"{delimiter}{few_shot_user_2}{delimiter}"},  
    {'role':'assistant', 'content': few_shot_assistant_2 },
    {'role':'user', 'content': f"{delimiter}{user_input}{delimiter}"},  
    ] 
    return get_completion_from_messages(messages)

这里我们在system_message 中增加了两句提示语:

 这两句话的意思是:不要输出任何非 JSON 格式的附加文本。输出请求的 JSON 后不要写任何解释性文字。

除此之外我们修改了原先的学习样本ew_shot_user_1 和few_shot_assistant_1 ,又增加了一对学习样本few_shot_user_2 和few_shot_assistant_2 。这样我们就有2对学习样本供LLM学习。

评估修改后的prompt对复杂问题的效果

customer_msg_4 = f"""
tell me about the CineView TV, the 8K one, Gamesphere console, the X one.
I'm on a budget, what computers do you have?"""

products_by_category_4 = find_category_and_product_v2(customer_msg_4,
                                                      products_and_category)
print(products_by_category_4)

从上面的结果上看,这次LLM按正确的格式输出了相关的产品和分类的内容,并且没有附带任何文本信息。因此说明我们修改后的prompt起了作业。

 回归测试:验证模型在以前的测试用例上仍然有效

 我们需要对之前的测试用例进行再次测试,以确保修改后的提示语对之前的测试用例仍然有效。这里我们抽取几个之前的测试用例进行测试。

customer_msg_0 = f"""Which TV can I buy if I'm on a budget?"""

products_by_category_0 = find_category_and_product_v2(customer_msg_0,
                                                      products_and_category)
print(products_by_category_0)

customer_msg_3 = f"""
tell me about the smartx pro phone and the fotosnap camera, the dslr one.
Also, what TVs do you have?"""

products_by_category_3 = find_category_and_product_v2(customer_msg_3,
                                                      products_and_category)
print(products_by_category_3)

 这里我们测试2条之前的测试用例,从输出结果上看完全满足要求。

建立用于自动化测试的测试用例集

下面我们要建立一个用于自动化测试的测试用例集,每个测试用例包含了客户的问题(customer_msg)和理想答案(ideal_answer)两部分内容,我们的目的是评估LLM的回复是否和理想答案一致,并以此给LLM打分。

msg_ideal_pairs_set = [
    
    # eg 0
    {'customer_msg':"""Which TV can I buy if I'm on a budget?""",
     'ideal_answer':{
        'Televisions and Home Theater Systems':set(
            ['CineView 4K TV', 'SoundMax Home Theater', 'CineView 8K TV', 'SoundMax Soundbar', 'CineView OLED TV']
        )}
    },

    # eg 1
    {'customer_msg':"""I need a charger for my smartphone""",
     'ideal_answer':{
        'Smartphones and Accessories':set(
            ['MobiTech PowerCase', 'MobiTech Wireless Charger', 'SmartX EarBuds']
        )}
    },
    # eg 2
    {'customer_msg':f"""What computers do you have?""",
     'ideal_answer':{
           'Computers and Laptops':set(
               ['TechPro Ultrabook', 'BlueWave Gaming Laptop', 'PowerLite Convertible', 'TechPro Desktop', 'BlueWave Chromebook'
               ])
                }
    },

    # eg 3
    {'customer_msg':f"""tell me about the smartx pro phone and \
    the fotosnap camera, the dslr one.\
    Also, what TVs do you have?""",
     'ideal_answer':{
        'Smartphones and Accessories':set(
            ['SmartX ProPhone']),
        'Cameras and Camcorders':set(
            ['FotoSnap DSLR Camera']),
        'Televisions and Home Theater Systems':set(
            ['CineView 4K TV', 'SoundMax Home Theater','CineView 8K TV', 'SoundMax Soundbar', 'CineView OLED TV'])
        }
    }, 
    
    # eg 4
    {'customer_msg':"""tell me about the CineView TV, the 8K one, Gamesphere console, the X one.
I'm on a budget, what computers do you have?""",
     'ideal_answer':{
        'Televisions and Home Theater Systems':set(
            ['CineView 8K TV']),
        'Gaming Consoles and Accessories':set(
            ['GameSphere X']),
        'Computers and Laptops':set(
            ['TechPro Ultrabook', 'BlueWave Gaming Laptop', 'PowerLite Convertible', 'TechPro Desktop', 'BlueWave Chromebook'])
        }
    },
    
    # eg 5
    {'customer_msg':f"""What smartphones do you have?""",
     'ideal_answer':{
           'Smartphones and Accessories':set(
               ['SmartX ProPhone', 'MobiTech PowerCase', 'SmartX MiniPhone', 'MobiTech Wireless Charger', 'SmartX EarBuds'
               ])
                    }
    },
    # eg 6
    {'customer_msg':f"""I'm on a budget.  Can you recommend some smartphones to me?""",
     'ideal_answer':{
        'Smartphones and Accessories':set(
            ['SmartX EarBuds', 'SmartX MiniPhone', 'MobiTech PowerCase', 'SmartX ProPhone', 'MobiTech Wireless Charger']
        )}
    },

    # eg 7 # this will output a subset of the ideal answer
    {'customer_msg':f"""What Gaming consoles would be good for my friend who is into racing games?""",
     'ideal_answer':{
        'Gaming Consoles and Accessories':set([
            'GameSphere X',
            'ProGamer Controller',
            'GameSphere Y',
            'ProGamer Racing Wheel',
            'GameSphere VR Headset'
     ])}
    },
    # eg 8
    {'customer_msg':f"""What could be a good present for my videographer friend?""",
     'ideal_answer': {
        'Cameras and Camcorders':set([
        'FotoSnap DSLR Camera', 'ActionCam 4K', 'FotoSnap Mirrorless Camera', 'ZoomMaster Camcorder', 'FotoSnap Instant Camera'
        ])}
    },
    
    # eg 9
    {'customer_msg':f"""I would like a hot tub time machine.""",
     'ideal_answer': []
    }
    
]

 测试自动化测试集

print(f'Customer message: {msg_ideal_pairs_set[7]["customer_msg"]}')
print(f'Ideal answer: {msg_ideal_pairs_set[7]["ideal_answer"]}')

通过比较理想答案来评估测试用例

这里我们定义一个评估函数用以评估LLM的返回结果和自动测试用例集中的理想答案做比较并计算得分。

import json
def eval_response_with_ideal(response,
                              ideal,
                              debug=False):
    
    if debug:
        print("response")
        print(response)
    
    # json.loads() expects double quotes, not single quotes
    json_like_str = response.replace("'",'"')
    
    # parse into a list of dictionaries
    l_of_d = json.loads(json_like_str)
    
    # special case when response is empty list
    if l_of_d == [] and ideal == []:
        return 1
    
    # otherwise, response is empty 
    # or ideal should be empty, there's a mismatch
    elif l_of_d == [] or ideal == []:
        return 0
    
    correct = 0    
    
    if debug:
        print("l_of_d is")
        print(l_of_d)
    for d in l_of_d:

        cat = d.get('category')
        prod_l = d.get('products')
        if cat and prod_l:
            # convert list to set for comparison
            prod_set = set(prod_l)
            # get ideal set of products
            ideal_cat = ideal.get(cat)
            if ideal_cat:
                prod_set_ideal = set(ideal.get(cat))
            else:
                if debug:
                    print(f"did not find category {cat} in ideal")
                    print(f"ideal: {ideal}")
                continue
                
            if debug:
                print("prod_set\n",prod_set)
                print()
                print("prod_set_ideal\n",prod_set_ideal)

            if prod_set == prod_set_ideal:
                if debug:
                    print("correct")
                correct +=1
            else:
                print("incorrect")
                print(f"prod_set: {prod_set}")
                print(f"prod_set_ideal: {prod_set_ideal}")
                if prod_set <= prod_set_ideal:
                    print("response is a subset of the ideal answer")
                elif prod_set >= prod_set_ideal:
                    print("response is a superset of the ideal answer")

    # count correct over total number of items in list
    pc_correct = correct / len(l_of_d)
        
    return pc_correct

 下面我们要让LLM来回答自动化测试集中的某个问题,然后将输出结果与自动化测试集中的理想回答做比较并计算得分。

response = find_category_and_product_v2(msg_ideal_pairs_set[7]["customer_msg"],
                                         products_and_category)
print(f'Resonse: {response}')

eval_response_with_ideal(response,
                              msg_ideal_pairs_set[7]["ideal_answer"])

 从输出结果上看,LLM返回的结果Resonse中的产品数量小于理想答案中的产品数量,所以Resonse只是理想结果的一个子集,由此看来Resonse的结果并不完整。

对所有测试用例进行评估并计算正确回复的比例

下面我们要对所有的测试用来进行评估,并计算正确的resonse所占比例。

# Note, this will not work if any of the api calls time out
score_accum = 0
for i, pair in enumerate(msg_ideal_pairs_set):
    print(f"example {i}")

    customer_msg = pair['customer_msg']
    ideal = pair['ideal_answer']

    # print("Customer message",customer_msg)
    # print("ideal:",ideal)
    response = find_category_and_product_v2(customer_msg,
                                                      products_and_category)

    # print("products_by_category",products_by_category)
    score = eval_response_with_ideal(response,ideal,debug=False)
    print(f"{i}: {score}")
    score_accum += score


n_examples = len(msg_ideal_pairs_set)
fraction_correct = score_accum / n_examples
print(f"Fraction correct out of {n_examples}: {fraction_correct}")

 我们测试了所有的测试用来,从返回的结果上看只有第7个问题的返回结果不完全正确,这个前面已经讨论过了,所以正确的回复是9个,不正确的回复有1个,所以最后得分是0.9。

总结

今天我们学习了如何评估LLM的回复的正确性,通过建立测试用例来测试LLM的回复,当LLM的回复不符合要求时,我们需要修改prompt来让LLM输出正确的结果,在修改prompt时我们在system_message中增加了控制输出结果的语句,同时增加少量学习样本(few-shot prompt),这样更好的微调了LLM,确保LLM按正确格式输出结果,最后我们通过建立自动化测试用例来评估LLM的回复是否与理想答案一致,并得到了LLM的评估分数。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/669232.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

Java 10 新特性解读

前言  2018年3月21日&#xff0c;Oracle官方宣布Java10正式发布。  需要注意的是 Java 9 和 Java 10 都不是 LTS (Long-Term-Support) 版本。和过去的 Java 大版本升级不同&#xff0c;这两个只有半年左右的开发和维护期。而未 来的 Java 11&#xff0c;也就是 18.9 LTS&am…

SpringBoot基于Aop实现自定义日志注解(提供Gitee源码)

前言&#xff1a;日志在我们的日常开发当中是必定会用到的&#xff0c;在每个方法的上都会习惯性打上Log注解&#xff0c;这样系统就会自动帮我们记录日志&#xff0c;整体的代码结构就会非常优雅&#xff0c;这边我自己搭建了一个demo去实现了一些这个项目当中必定会用的功能。…

根据jar名称动态打包带版本的镜像, 并创建对应容器的脚本实现

根据jar名称动态打包带版本的镜像以及容器 利用shell脚本, 实现根据jar名称中的项目名和版本号来动态制作带版本的Docker镜像以及带版本的容器 背景 人人都逃不过的墨菲定律 事情的原因来自最近发生的一次生产环境事故: 我们在甲方那里环境中有两个服务器, 一个用于灰度测试另…

WPF开发txt阅读器16:自动编码检测

文章目录 更改编码重新载入自动编码检测更改编码并保存 txt阅读器系列&#xff1a; 需求分析和文件读写目录提取类&#x1f48e;列表控件与目录&#x1f48e;快捷键翻页字体控件绑定&#x1f48e;前景/背景颜色书籍管理系统&#x1f48e;用树形图管理书籍语音播放&#x1f48e…

Cortext-M3系统:储存器系统(2)

1、存储系统功能概览 Cortext-M3储存器有如下特点&#xff1a; 存储器映射是预定义的&#xff0c;并且还规定好了哪个位置使用哪条总线。 存储器系统支持所谓的“位带”&#xff08;bit-band&#xff09;操作。通过它&#xff0c;实现了对单一比特的原子操作&#xff0c;位带操…

STM32G0+EMW3080+阿里云实现单片机WiFi智能联网功能(一)EMW3080实现和PC之间的串口通讯

项目描述&#xff1a;该系列记录了STM32G0EMW3080实现单片机智能联网功能项目的从零开始一步步的实现过程&#xff1b; 硬件环境&#xff1a;单片机为STM32G030C8T6&#xff1b;物联网模块为EMW3080V2-P&#xff1b;网联网模块的开发板为MXKit开发套件&#xff0c;具体型号为XC…

基于tensorflow深度学习的猫狗分类识别

&#x1f935;‍♂️ 个人主页&#xff1a;艾派森的个人主页 ✍&#x1f3fb;作者简介&#xff1a;Python学习者 &#x1f40b; 希望大家多多支持&#xff0c;我们一起进步&#xff01;&#x1f604; 如果文章对你有帮助的话&#xff0c; 欢迎评论 &#x1f4ac;点赞&#x1f4…

Triton教程 --- 速率限制器

Triton教程 — 速率限制器 Triton系列教程: 快速开始利用Triton部署你自己的模型Triton架构模型仓库存储代理模型设置优化动态批处理 速率限制器 速率限制器管理 Triton 在模型实例上调度请求的速率。 速率限制器在 Triton 中加载的所有模型上运行&#xff0c;以允许跨模型优…

带你用Python制作7个程序,让你感受到端午节的快乐

名字&#xff1a;阿玥的小东东 学习&#xff1a;Python、C/C 主页链接&#xff1a;阿玥的小东东的博客_CSDN博客-python&&c高级知识,过年必备,C/C知识讲解领域博主 目录 前言 程序1&#xff1a;制作粽子 程序2&#xff1a;龙舟比赛 程序3&#xff1a;艾草挂 程序4…

基于Java高校共享单车管理系统设计实现(源码+lw+部署文档+讲解等)

博主介绍&#xff1a; ✌全网粉丝30W,csdn特邀作者、博客专家、CSDN新星计划导师、java领域优质创作者,博客之星、掘金/华为云/阿里云/InfoQ等平台优质作者、专注于Java技术领域和毕业项目实战 ✌ &#x1f345; 文末获取源码联系 &#x1f345; &#x1f447;&#x1f3fb; 精…

《网络安全0-100》网络安全的未来趋势

网络安全的未来趋势 网络安全是一个永恒的话题&#xff0c;随着技术的发展 和应用&#xff0c;网络安全也面临着新的挑战和威胁。 以下是网络安全未来的趋势&#xff1a; 人工智能和机器学习&#xff1a;人工智能和机器学习已 经成为网络安全领域的热门技术。未来&#xff…

编译原理笔记11:自上而下语法分析(1)基础概念、左递归和公共左因子处理、递归下降分析(咕咕咕)

目录 自上而下分析的一般方法用推导的方法分析输入序列左递归问题及其消除&#xff08;消除左递归&#xff09;消除直接左递归消除间接左递归左递归消除算法 公共左因子问题及其消除&#xff08;提取左因子&#xff09;提取左因子 递归下降分析 词法分析&#xff0c;是把源程序…

基于物联网及云平台的光伏运维系统

系统结构 在光伏变电站安装逆变器、以及多功能电力计量仪表&#xff0c;通过网关将采集的数据上传至服务器&#xff0c;并将数据进行集中存储管理。用户可以通过PC访问平台&#xff0c;及时获取分布式光伏电站的运行情况以及各逆变器运行状况。平台整体结构如图所示。 光伏背景…

Cortext-M3系列:调试组件(9)

1、调试组件简介 在 CM3 中有很多调试组件&#xff0c;使用它们可以执行各种调试功能&#xff1a;断点、数据观察点、闪存地址重载以及各种跟踪等。软件开发人员也许永远无需了解调试组 的细节&#xff0c;因为它们通常只是由调试器及其周边工具使用的。 本文对每种调试组件做一…

基于Java学生公寓管理中心系统设计实现(源码+lw+部署文档+讲解等)

博主介绍&#xff1a; ✌全网粉丝30W,csdn特邀作者、博客专家、CSDN新星计划导师、java领域优质创作者,博客之星、掘金/华为云/阿里云/InfoQ等平台优质作者、专注于Java技术领域和毕业项目实战 ✌ &#x1f345; 文末获取源码联系 &#x1f345; &#x1f447;&#x1f3fb; 精…

IDEA2022.3.3支持Jrebel and Xrebel教程

目录 前言 思路 步骤 1、下载服务并启动 推荐下载windows环境的exe文件&#xff0c;直接点开就行。 如果用linux 需要安装go环境: 下载好后启动 2、idea安装Jrebel and XRebel插件 3、激活插件 前言 由于服务平台限制&#xff0c;只支持darwin、linux和windows环境。这…

(转载)无监督学习神经网络的分类(matlab实现)

对于监督学习神经网络&#xff0c;事先需要知道与输入相对应的期望输出&#xff0c;根据期望输出与网络输出间的偏差来调整网络的权值和阈值。然而&#xff0c;在大多数情况下&#xff0c;由于人们认知能力以及环境的限制&#xff0c;往往无法或者很难获得期望的输出&#xff0…

AbstractQueuedSynchronizer源码

介绍 基于队列的抽象同步器&#xff0c;它是jdk中所有显示的线程同步工具的基础&#xff0c;像ReentrantLock/DelayQueue/CountdownLatch等等&#xff0c;都是借助AQS实现的。 public abstract class AbstractQueuedSynchronizerextends AbstractOwnableSynchronizerimplemen…

Camera 基础知识点

和你一起终身学习&#xff0c;这里是程序员Android 经典好文推荐&#xff0c;通过阅读本文&#xff0c;您将收获以下知识点: 1.1 Camera 工作原理1.2 Camera 模组组成1.3 Camera 常见缩写解释1.4 Camera 部分名词解释1.5 参考文献 一、Camera 基础知识 1.1 Camera 工作原理 外部…

[进阶]Java:线程安全问题、取钱模拟

什么是线程安全问题&#xff1f; 多个线程&#xff0c;同时操作同一个共享资源的时候&#xff0c;可能会出现业务安全问题。 线程安全问题出现的原因&#xff1f; 存在多个线程在同时执行同时访问一个共享资源存在修改该共享资源 代码演示如下&#xff1a; 账户类&#xff…