Face living body recognition method and system based on self-constructing reasoning chain, medium and product
The face liveness detection method using a self-constructed inference chain generates a structured text inference chain by utilizing a multimodal large model and a reinforcement learning framework. This solves the problems of transparency and explainability of face recognition systems under liveness attacks, and achieves traceability and auditability in high-security application scenarios.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-10
- Publication Date
- 2026-04-07
AI Technical Summary
Existing facial recognition systems lack transparency and explainability when facing liveness attacks, and the black-box nature of deep learning models makes it difficult to trace the cause of misjudgments, thus failing to meet the needs of high-security application scenarios.
A face liveness detection method using a self-constructed inference chain is proposed. This method encodes features from images and text commands using a multimodal large model and introduces a reinforcement learning framework to generate a structured text inference chain. Finally, a policy network is used to generate an interpretable decision process that includes the inference process.
It improves the transparency and interpretability of the decision-making process for liveness detection technology, meets the traceability and auditability requirements in high-security application scenarios, and reduces the instability and misjudgment risk of model training.
Smart Images

Figure CN121281147B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer systems based on specific computational models, and in particular to a method, system, medium, and product for facial liveness recognition using a self-constructed inference chain. Background Technology
[0002] With the rapid development of mobile internet and digital identity authentication technologies, facial recognition technology has been widely used in fields such as financial payments, access control and security, and remote identity verification. However, facial recognition systems face an increasingly serious threat of liveness detection attacks. Attackers may use photos, videos, or 3D masks to deceive the system and bypass the identity authentication mechanism. Therefore, accurate and reliable facial liveness detection technology has become a key technical link in ensuring the security of identity authentication systems, and its importance is becoming increasingly prominent.
[0003] In related technologies, face liveness detection technology is mainly based on deep learning-based binary classification methods. It extracts deep features from face images by constructing a convolutional neural network model and uses these features to train a classifier to distinguish between real faces and attack samples. Typically, a pre-trained convolutional neural network is used as a feature extractor to extract high-dimensional feature vectors from the input face image. Then, fully connected layers are connected to these feature vectors to form a classifier. The model parameters are trained through supervised learning, and the final model outputs a probability value or confidence score to determine whether a face is a live or attack sample. This method, through end-to-end training, can automatically learn discriminative features and achieves good detection accuracy on standard test sets.
[0004] However, since deep neural networks in related technologies are black-box models, in application scenarios with extremely high requirements for security and credibility, such as financial payments and judicial evidence collection, the opacity of the black box makes it difficult to trace the cause of errors when the system makes a misjudgment, and makes it difficult to perform security audits and compliance checks. Summary of the Invention
[0005] This application provides a face liveness detection method, system, medium, and product with a self-constructed inference chain, which aims to improve the problems of opaque and unexplainable decision-making processes in liveness detection technology.
[0006] Firstly, this application provides a self-constructed inference chain-based face liveness detection method, applied to a face liveness detection system. The method includes: performing face detection and face segmentation on an initial face image, and normalizing it to a standard face image; based on a multimodal large model, performing feature encoding on the standard face image and a pre-set task instruction text used to guide the liveness detection task, respectively, to obtain image feature vectors and text feature vectors, serving as the initial state of the reinforcement learning environment; inputting the initial state into a policy network, and generating multiple candidate inference chains through multiple samplings of the policy network; the candidate inference chain is a structured text format containing the inference process and the detection answer; calculating a correctness reward based on the label matching degree between the candidate inference chain and the real label, and calculating a format normalization reward based on the text matching degree between the candidate inference chain and the structured text format, determining multiple output reward values for the multiple candidate inference chains; calculating an advantage function for the multiple candidate inference chains and their corresponding output reward values, and adjusting the weight parameters of the policy network based on the advantage function to obtain an optimized policy network; determining the optimal inference chain based on the optimized policy network, and determining the liveness detection result and inference process description based on the optimal inference chain.
[0007] In the above embodiments, the face liveness recognition system adopts the above technical solution, uses a multimodal large model to uniformly encode images and text commands, and introduces a reinforcement learning framework to generate structured text containing the reasoning process through a policy network. This transforms the decision-making process of liveness detection into a generative and evaluable reasoning chain construction task, improving the interpretability of the decision-making process of liveness detection technology. This facilitates developers to make targeted adjustments to the liveness detection technology. At the same time, due to the existence of the reasoning chain language, it meets the traceability and auditability requirements in high-security application scenarios.
[0008] In conjunction with some embodiments of the first aspect, in some embodiments, the step of calculating an advantage function for multiple sets of candidate inference chains and their corresponding output reward values, and adjusting the weight parameters of the policy network based on the advantage function to obtain an optimized policy network, specifically includes: calculating a baseline value based on multiple output reward values, and determining the difference between each output reward value and the baseline value as the corresponding advantage value; calculating the policy gradient based on the action probability of the candidate inference chain during the generation process and the corresponding advantage value, and determining the weight parameter update amount of each layer in the policy network; updating the weight parameters of the policy network based on the weight parameter update amount to obtain the optimized policy network.
[0009] In the above embodiments, the face liveness recognition system, by adopting the above technical solution, introduces an advantage function in reinforcement learning training. The advantage value is determined by calculating the difference between each reward value and the baseline value, which can effectively reduce the variance of the reward signal, avoid the training instability problem caused by excessive fluctuations in reward value, and improve the convergence speed of model training.
[0010] In conjunction with some embodiments of the first aspect, in some embodiments, after calculating the policy gradient based on the action probabilities and corresponding advantage values of the candidate inference chain during the generation process, and determining the weight parameter update amount of each layer in the policy network, the method further includes: when the gradient norm of the weight parameter update amount exceeds a preset threshold range, performing a gradient pruning operation on the weight parameter update amount to scale the gradient components that exceed the range to the preset threshold range, thereby obtaining the pruned parameter update amount; updating the weight parameters of the policy network based on the pruned parameter update amount to obtain a corrected policy network.
[0011] In the above embodiments, the face liveness recognition system, by adopting the above technical solution, ensures the stability of the model training process by limiting the gradient norm within a preset threshold during the policy network training process.
[0012] In conjunction with some embodiments of the first aspect, in some embodiments, before calculating the correctness reward based on the label matching degree between the candidate inference chain and the real label, calculating the format normalization reward based on the text matching degree between the candidate inference chain and the structured text format, and determining multiple output reward values for multiple groups of candidate inference chains, the method further includes: grouping the candidate inference chains according to the number of inference steps to obtain multiple inference length groups; performing semantic similarity clustering on the candidate inference chains within each inference length group to obtain multiple inference chain clusters with the same inference pattern; determining the central inference chain and the boundary inference chain in each inference chain cluster; and determining the inference diversity coefficient based on the semantic distance between the central inference chain and the boundary inference chain as an adjustment factor in the calculation formula of the correctness reward.
[0013] In the above embodiments, the face liveness recognition system, by adopting the above technical solution, performs cluster analysis on the generated candidate inference chains, evaluates different inference patterns and incorporates them as adjustment factors into the reward function, which can incentivize the policy network to explore more inference paths and increase the possibility of discovering better inference logic.
[0014] In conjunction with some embodiments of the first aspect, in some embodiments, after determining the central inference chain and boundary inference chains in each inference chain cluster, the method further includes: extracting key feature words from the central inference chain and constructing an inference feature dictionary; evaluating the feature coverage of candidate inference chains based on the inference feature dictionary and calculating the number of feature words covered by each candidate inference chain; determining an inference density index based on the ratio of the number of feature words to the length of the candidate inference chain; and generating a composite adjustment factor based on the inference density index and the inference diversity coefficient.
[0015] In the above embodiments, the face liveness recognition system adopts the above technical solution, constructs a key feature dictionary and evaluates the feature coverage of each inference chain, encourages the model to explore diverse inference paths, guides it to generate a more concise and information-dense inference chain, and makes the final output explanation more refined.
[0016] In conjunction with some embodiments of the first aspect, in some embodiments, after determining the optimal inference chain based on the optimization strategy network, and determining the liveness detection result and inference process description based on the optimal inference chain, the method further includes: performing reverse verification on the optimal inference chain, inputting the liveness detection result as an assumption into the verification model, and deriving verification features corresponding to the original image features based on the reverse inference path; calculating the similarity between the verification features and the original image features to obtain the feature matching degree; calculating the inference reversibility score of the reverse inference path and the optimal inference chain based on the feature matching degree; and when the inference reversibility score is lower than a preset reversibility threshold, reselecting the suboptimal inference chain from the candidate inference chains and performing reverse verification on the suboptimal inference chain.
[0017] In the above embodiments, the face liveness recognition system adopts the above technical solution, and when the optimal inference chain fails to pass the verification, the system will select the suboptimal chain for alternative verification, which ensures the reliability of the final output result and reduces the risk of misjudgment.
[0018] In conjunction with some embodiments of the first aspect, in some embodiments, the step of reverse verification of the optimal inference chain, using the liveness detection result as an assumption input into the verification model, and deriving verification features corresponding to the original image features based on the reverse inference path, specifically includes: converting the liveness detection result into a set of feature constraints; the set of feature constraints includes essential liveness feature conditions and exclusion conditions for non-liveness features; performing constraint solving in a multi-dimensional feature space based on the set of feature constraints to determine feature candidate regions that satisfy the essential liveness feature conditions or exclusion conditions for non-liveness features; extracting key feature vectors in the feature candidate regions according to feature importance weights, arranging the key feature vectors in reverse inference order to generate a reverse feature sequence; reconstructing the image feature representation based on the reverse feature sequence to generate verification features corresponding to the original image features.
[0019] In the above embodiments, the face liveness recognition system, by adopting the above technical solution, transforms the discrimination result into a constraint condition of the feature space, and solves and reconstructs the verification features under this constraint, thereby ensuring the accuracy of the logical reversibility of the inference chain.
[0020] In a second aspect, embodiments of this application provide a face liveness recognition system, which includes: one or more processors and a memory; the memory is coupled to the one or more processors, and the memory is used to store computer program code, which includes computer instructions, and the one or more processors call the computer instructions to cause the face liveness recognition system to perform the method described in the first aspect and any possible implementation thereof.
[0021] Thirdly, embodiments of this application provide a computer program product containing instructions that, when the computer program product is run on a face liveness recognition system, cause the face liveness recognition system to perform the method described in the first aspect and any possible implementation thereof.
[0022] Fourthly, embodiments of this application provide a computer-readable storage medium including instructions that, when executed on a face liveness recognition system, cause the face liveness recognition system to perform the method described in the first aspect and any possible implementation thereof.
[0023] Understandably, the face liveness recognition system provided in the second aspect, the computer program product provided in the third aspect, and the computer storage medium provided in the fourth aspect are all used to execute the methods provided in the embodiments of this application. Therefore, the beneficial effects they can achieve can be referred to the beneficial effects in the corresponding methods, and will not be repeated here.
[0024] One or more technical solutions provided in the embodiments of this application have at least the following technical effects or advantages:
[0025] 1. By adopting a technical solution based on multimodal large model for feature encoding and combining it with the policy network in the reinforcement learning framework to generate structured text inference chains, the face liveness recognition system can transform the input image and task instructions into readable text containing the discrimination criteria and conclusions; thus solving the problem that deep learning models in the prior art are black boxes, resulting in opaque decision-making processes and difficulty in interpreting the judgment criteria.
[0026] 2. Because the system adopts a technique based on the advantage function and policy gradient to optimize the policy network, it can obtain more stable and efficient guidance signals during the training process of reinforcement learning. This makes the direction of each parameter update clearer, that is, adjusting in a direction that is better than the average performance. This avoids the problems of unstable model training, slow convergence or getting stuck in local optima caused by a huge exploration space, sparse reward signals or noise.
[0027] 3. Because the system adopts a technical solution that introduces the inference diversity coefficient as a moderating factor into the reward function, it calculates the diversity coefficient by semantically clustering the generated candidate inference chains and quantifying the differences between different inference clusters when training the policy network. This avoids the model from repeatedly generating a few safe but potentially suboptimal outputs. Attached Figure Description
[0028] Figure 1 This is a flowchart illustrating a face liveness detection method using a self-constructed inference chain in an embodiment of this application.
[0029] Figure 2 This is a schematic diagram of the topology of a face liveness recognition system in an embodiment of this application;
[0030] Figure 3 This is another flowchart illustrating the face liveness recognition method with a self-constructed inference chain in the embodiments of this application;
[0031] Figure 4 This is a schematic diagram of the physical device structure of a face liveness recognition system in the embodiments of this application. Detailed Implementation
[0032] The terminology used in the following embodiments of this application is for the purpose of describing particular embodiments only and is not intended to be limiting of this application. As used in the specification of this application, the singular expressions “a,” “an,” “the,” “the,” and “this” are intended to include the plural expressions as well, unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used in this application refers to any or all possible combinations including one or more of the listed items.
[0033] Hereinafter, the terms "first" and "second" are used for descriptive purposes only and should not be construed as implying or suggesting relative importance or implicitly indicating the number of indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature, and in the description of the embodiments of this application, unless otherwise stated, "multiple" means two or more.
[0034] In the specific implementation scenario of this application, the multimodal large model refers to a deep learning model capable of simultaneously processing and understanding multiple different types of data (in this case, images and text). It represents the visual information of face images and the semantic information of task instruction text through a unified feature space. The reinforcement learning environment is the core framework of the entire methodology, defining the liveness detection task as a sequential decision problem, where the initial state is composed of features encoded by the multimodal model. The policy network, as the agent in reinforcement learning, determines the next action based on the current state, i.e., generating the next word or sentence in the inference chain. The inference chain is the core output of this method; it is a structured text that not only contains the final liveness detection answer (e.g., live or attack) but also records in detail the logical deduction steps from visual evidence to the final conclusion, for example:
[0035] Step 1: Moiré patterns were detected in the face area.
[0036] Step 2: Moiré patterns are a typical feature of screen reproduction.
[0037] Conclusion: This was determined to be a screen attack.
[0038] The advantage function is a key concept in reinforcement learning optimization algorithms (such as PPO). It evaluates the superiority of an action by comparing the reward obtained from the current action with a baseline (the expected value of the state), thereby providing a more stable learning signal.
[0039] The entire process can be understood as follows: the system first receives a facial image and task requirements, and then, in a virtual learning environment, a continuously learning and evolving policy network attempts to write multiple problem-solving approaches (candidate inference chains). These approaches are then scored based on their correctness, standardization, diversity, etc. (reward value is calculated), and the scoring results and superiority evaluation (advantage function) are used to guide the system to improve its problem-solving methods. Finally, the optimal problem-solving approach (optimal inference chain) is found as the output. This achieves the interpretability of the entire facial image recognition process, making it easier for researchers to perform targeted optimization and parameter adjustment for each process of facial image recognition technology.
[0040] The following describes the process of the method provided in this implementation. Please refer to [link / reference]. Figure 1 This is a flowchart illustrating a face liveness detection method using a self-constructed inference chain in an embodiment of this application.
[0041] S101. Perform face detection and face segmentation on the initial face image, and normalize it into a standard face image.
[0042] Please see Figure 2 This is a schematic diagram of the topology of a face liveness recognition system in an embodiment of this application. Figure 2The system comprises an input module, a feature encoding module, a policy reasoning module, and an output module. This step corresponds to the function of the input module. This input module is responsible for receiving the initial face image from an external acquisition device (such as a camera) and performing preprocessing operations.
[0043] The initial face image refers to the original image frame acquired from a camera or other image acquisition device, which may contain complex backgrounds and multiple faces. Normalization processing refers to the process of transforming cropped face images of varying sizes and angles into face images with fixed dimensions and standard poses through geometric transformations such as scaling, rotation, and alignment, for example, uniformly forming a 224x224 pixel frontal face image.
[0044] Specifically, when a face liveness detection system receives a video stream containing a face or a still photograph, it first calls a face detection algorithm (such as MTCNN or YOLO series) to scan the entire image to determine whether a face exists and its precise location. If detection is successful, the system separates the face region from the background based on the returned coordinates. To eliminate differences caused by factors such as shooting distance and head posture, the system also performs alignment operations on the cropped face image. That is, based on detected key points such as eyes, nose, and mouth, the face is rotated and scaled to a preset standard size to ensure that faces input into subsequent models have a consistent format.
[0045] S102. Based on the multimodal large model, feature encoding is performed on the standard face image and the preset task instruction text used to guide the liveness detection task, respectively, to obtain image feature vectors and text feature vectors, which serve as the initial state of the reinforcement learning environment.
[0046] Please see Figure 2 This is a schematic diagram of the topology of the face liveness recognition system in this application embodiment. This step mainly corresponds to... Figure 2 The module describes the functions of the input module and the feature encoding module. The feature encoding module receives a standard face image from the input module and simultaneously receives the task instruction text from the other end of the input module. A multimodal large model is deployed within the module, which includes a parallel visual encoder and a text encoder. The visual encoder is responsible for converting image pixels into high-dimensional image feature vectors, while the text encoder converts the task instruction text into high-dimensional text feature vectors. Figure 2 In the image and text query, tokens (feature vectors) for subsequent processing are generated by visual encoder and text encoder, respectively.
[0047] In this context, a multimodal large model refers to a large neural network model capable of jointly processing both image and text modal information, such as CLIP or BLIP. Task instruction text is pre-set text by developers or users to explain the task to be performed to the model, such as determining whether this face image is a live person and providing the reasoning process. Feature encoding refers to transforming the raw image pixels and text characters into high-dimensional feature vectors through the model.
[0048] Specifically, after preprocessing, the face liveness recognition system inputs a standard face image into the visual encoder of a multimodal large-scale model, while simultaneously inputting the task instruction text (query) into its text encoder. The visual encoder decomposes the image into a series of patches and converts them into a set of image feature vectors. The text encoder tokenizes the text and converts each word into a text feature vector. Both the visual and text encoders are pre-trained on a large-scale dataset and are capable of recognizing visual and semantic information. The system concatenates or fuses the output image and text feature vectors to form a unified high-dimensional vector representation, constituting the initial state of the reinforcement learning environment. This initial state serves as the context information for policy network inference.
[0049] S103. Input the initial state into the policy network, and generate multiple candidate inference chains by sampling the policy network multiple times.
[0050] Please see Figure 2 This is a schematic diagram of the topology of the face liveness recognition system in this application embodiment. This step mainly corresponds to... Figure 2 The policy inference module is a generative language model based on a policy network. It receives the initial state from the feature encoding module as input and, using this as a condition, performs an autoregressive text generation process. The policy inference module is configured in sampling mode, generating multiple sets of candidate inference chains with distinct content through multiple independent generation processes, as shown in the diagram. .
[0051] Sampling refers to selecting a word from the probability distribution of the next word predicted by the policy network, according to a certain degree of randomness (such as temperature sampling).
[0052] Specifically, the face liveness recognition system takes the initial state vector obtained in step S102 as input and feeds it into the policy network. The policy network then begins to autoregressively generate text based on this vector. At each step, the model outputs a probability distribution of all words in the vocabulary, indicating the next most likely word. Instead of always selecting the word with the highest probability (a greedy strategy), the system introduces a degree of randomness by using temperature-controlled sampling or Top-k / Top-p sampling to select the next word. This process is repeated until a special marker indicating the end of a sentence is generated, thus creating a complete candidate inference chain. By repeating the entire generation process multiple times (e.g., running it G times), the system can obtain G sets of candidate inference chains, each with potentially different content. , ,..., ).
[0053] In some embodiments, to make the reasoning process clear and parsable, candidate reasoning chains are required to strictly adhere to a specific structured format, such as:
[0054] <think> Reasoning process< / think>
[0055] <answer> Living / Prosthesis< / answer> .
[0056] The size G of the sampling group can be set to 4, meaning that 4 candidate inference chains are generated each time. To control computational overhead, the maximum generation length of each inference chain can be limited to 128 tokens.
[0057] In some embodiments, it is necessary to address the factual illusion in the generated inference chain, where the model may fabricate visual evidence that does not exist in the image to support its conclusions (e.g., the image is clear, but the inference chain states the image is blurry). To address this, a factual consistency verification mechanism can be introduced. An auxiliary discriminative model can be trained that takes an image and a statement (e.g., the presence of moiré patterns in the image) and outputs the probability that the statement is consistent with the image content. At each step of the policy network generating the inference chain, or after generation, this discriminative model can be used to verify whether the generated text fragment matches the image facts. The verification result can be used as an additional reward signal or constraint to penalize generation behaviors that produce factual illusions, guiding the policy network to generate inferences that are more faithful to the image content.
[0058] S104. Calculate the correctness reward based on the tag matching degree between the candidate inference chain and the real tag, calculate the format standardization reward based on the text matching degree between the candidate inference chain and the structured text format, and determine multiple output reward values for the multiple sets of candidate inference chains.
[0059] Please see Figure 2This is a schematic diagram of a topology of the face liveness recognition system in an embodiment of this application. This step corresponds to... Figure 2 The reward calculation unit is located within the strategy reasoning module. This unit receives multiple candidate reasoning chains generated by the strategy reasoning module and simultaneously obtains the corresponding ground truth labels. The core task of this unit is to calculate the reward for each candidate reasoning chain according to a preset reward function. The evaluation is conducted, scoring both content accuracy and format compliance, and ultimately outputting a set of inference chains for each candidate. Corresponding reward value .
[0060] Here, the true label refers to the true classification of the face image, i.e., live or botched (fake). Label matching degree is used to measure whether the conclusions drawn in the candidate inference chain are consistent with the true label. Structured text format refers to the predefined text organization form that the inference chain should follow.
[0061] Specifically, for each generated candidate inference chain (e.g.) , ,..., The facial liveness detection system performs two evaluations. First, the system analyzes... Extract the final judgment answer contained therein (e.g., from...) <answer> living< / answer> (The system extracts liveness detection data). Then, it compares the extracted answer with the image's true label. If they match, a higher reward is given; otherwise, a penalty is imposed. Next, the system uses methods such as regular expressions or template matching to check... Does it follow a predefined structured format? A format conformity reward is given based on the degree of matching. Finally, the correctness reward and the format conformity reward are combined using a weighted summation method to obtain the candidate inference chain. Corresponding final output reward value .
[0062] The correctness of the format is verified using regular expressions, and the rules may include:
[0063] a) Existence of complete <think>Open and closed tag pairs;
[0064] b) Existence of complete <answer>Open and closed tag pairs;
[0065] c) <think>and <answer>There is no non-label bare text between the labels.
[0066] In some embodiments, a reward mechanism can be designed. For example, during the process of generating inference chains by the policy network, a small immediate reward is given for each sentence that is logically consistent with the image facts. In addition, a reference model (such as the reference model shown in Figure 2 , for example, an initial, unoptimized policy network or a frozen CLIP text decoder) can also evaluate the probability of generating a sequence. The KL divergence between the probability of generating a sequence by the current policy model and the probability of generating a sequence by the reference model can be added to the reward or objective function as a penalty term, which can prevent the policy model from deviating too far from the useful knowledge learned during pre-training during optimization, and can stabilize training.
[0067] S105, calculate the advantage function for the multiple groups of candidate inference chains and the corresponding output reward values, and adjust the weight parameters of the policy network based on the advantage function to obtain an optimized policy network.
[0068] Please refer to Figure 2 , which is a topological structure diagram of a face living body recognition system in the embodiments of the present application. The present step corresponds to the system training loop in the policy inference module in Figure 2 . The policy inference module receives the reward values from the reward calculation unit and calculates the advantage function using these reward values. The gradient is calculated according to the advantage function, and the gradient is used to update the internal policy network weight parameters. Through the training loop of generation-evaluation-optimization, the performance of the policy inference module can be improved to obtain the optimal model.
[0069] Among them, the advantage function is a core concept in reinforcement learning, which is expressed as:
[0070] A(s, a) = Q(s, a) - V(s), that is, the value of action a in state s minus the average value of state s itself, which measures the advantage of action a relative to the average level.
[0071] Specifically, after the face living body recognition system collects G groups of candidate inference chains and their corresponding reward values , a baseline value (Baseline) is first calculated, which is the average of the G reward values. Then, for each inference chain , its advantage value is calculated as minus the baseline value. This advantage value represents whether the performance of the current sample is better or worse than the average level of the previous samples. Then, the system uses these advantage values to calculate the policy gradient and updates the weights of the policy network according to the policy gradient. A positive advantage value will increase the probability of generating the corresponding inference chain, while a negative advantage value will decrease the probability. This step S105 is iterated until the performance of the policy network converges, and finally an optimized policy network is obtained.
[0072] In some embodiments, this step employs a GRPO algorithm for model optimization. This algorithm does not rely on an independent value network, but uses the statistics of group rewards to calculate the normalized advantage function. Specifically, for a group of rewards , ,..., }, first calculate their mean and standard deviation . Then, the normalized advantage value of each candidate inference chain is calculated as: = ( - ) / ( ). The method of intra-group normalization can effectively reduce the variance of the reward and provide a more stable learning signal.
[0073] Subsequently, a PPO-like objective function is optimized based on this advantage function. This objective function aims to maximize the expected advantage while constraining the update magnitude of the policy through clipping and KL divergence regularization. The GRPO objective function can be represented as:
[0074] L(θ) = E[min(ratio(θ)*Â, clip(ratio(θ), 1-ε, 1+ε)*Â)] - β*KL( || ); where ratio(θ) is the probability ratio of the new policy and the old policy (the policy parameter snapshot before updating); Â is the normalized advantage value; the clip function limits the probability ratio to the range of [1-ε, 1+ε] to prevent the update step from being too large; ε is the clipping range hyperparameter, for example 0.2; KL( || ) is the KL divergence between the current policy and a fixed reference policy (such as the initial, frozen CLIP text decoder), used for regularization to prevent the policy from forgetting pre-training knowledge; β is the weight of the KL regularization term, for example 0.05. The gradient of this objective function is calculated and backpropagated to update the parameters of the policy network .
[0075] It should be noted that the gradient not only updates the policy network (Transformer model), but also backpropagates to the image encoder of CLIP, thereby realizing the end-to-end fine-tuning of the visual feature extractor. The entire optimization process can use the AdamW optimizer, with a learning rate of 1e-5 and a weight decay coefficient of 0.01.
[0076] In some embodiments, it is necessary to accurately estimate the advantage function, because inaccurate estimation will introduce high variance, leading to unstable training. The in-group normalized advantage function used in GRPO =( - ) / , by standardizing within each small batch (group), reduces the computational and storage overhead, while providing each sample with a relative good or bad degree relative to the average performance of the current batch, suitable for sparse reward scenarios where rewards are only provided at the end of the sequence.
[0077] S106, determine the optimal inference chain based on the optimized policy network, and determine the living body discrimination result and the inference process description according to the optimal inference chain.
[0078] Please refer to Figure 2 , a topological structure diagram of a face living body recognition system in the embodiments of the present application, the present step corresponds to the strategy inference module and the output module in Figure 2 . The strategy inference module receives new input and performs deterministic inference to generate the optimal inference chain , and passes the optimal inference chain to the output module. The output module is responsible for parsing the inference chain and extracting the final discrimination result and the explainable inference process description.
[0079] Among them, the living body discrimination result is the final conclusion (living body or attack) extracted from the optimal inference chain. The inference process description is the text content in the optimal inference chain that describes the analysis process.
[0080] Specifically, when a new standard face image needs to be discriminated, the face living body recognition system will no longer perform multiple random sampling and training, but will use the already optimized policy network for inference. The system inputs the initial state after encoding the image and task instruction into the optimized policy network. At this time, a deterministic generation strategy such as greedy search (selecting the word with the highest probability at each step) or beam search is used to generate one or a few candidate inference chains with the highest quality. The system selects the optimal one (e.g., the one with the highest score in beam search) from these generated inference chains, parses the optimal inference chain, takes the conclusion part as the final living body discrimination result, and takes the analysis part as the inference process description of the result, and displays it to the user or records it in the log.
[0081] The method provided by the present embodiment is further described in more detail below. Please refer to Figure 3 , another flowchart of the face liveness recognition method based on self-constructed reasoning chain in the embodiment of the present application.
[0082] S301, face detection and face cutting of the initial face image are performed, and the initial face image is normalized into a standard face image. Please refer to step S101, which is not repeated here.
[0083] S302, based on the multi-modal large model, the standard face image and the pre-set task instruction text for guiding the liveness discrimination task are respectively encoded to obtain image feature vectors and text feature vectors as the initial state of the reinforcement learning environment. Please refer to step S102, which is not repeated here.
[0084] S303, the initial state is input to the policy network, and multiple groups of candidate reasoning chains are generated by multiple samplings of the policy network. Please refer to step S103, which is not repeated here.
[0085] S304, the correctness reward is calculated according to the label matching degree of the candidate reasoning chain and the true label, and the format standardization reward is calculated according to the text matching degree of the candidate reasoning chain and the structured text format, and multiple output reward values of the multiple groups of candidate reasoning chains are determined. Please refer to step S104, which is not repeated here.
[0086] In some embodiments, the face liveness recognition system introduces a diversity reward to enrich the reasoning mode, that is, the face liveness recognition system groups the candidate reasoning chains according to the number of reasoning steps to obtain multiple reasoning length groups; performs semantic similarity clustering on the candidate reasoning chains in each reasoning length group to obtain multiple reasoning chain clusters with the same reasoning mode; determines the center reasoning chain and the boundary reasoning chain in each reasoning chain cluster; and determines the reasoning diversity coefficient based on the semantic distance between the center reasoning chain and the boundary reasoning chain as an adjustment factor in the calculation formula of the correctness reward.
[0087] Wherein, the reasoning length group is a set of generated reasoning chains classified according to the number of sentences or steps contained. Semantic similarity clustering is a technique that uses sentence vectors to divide reasoning chains with similar meanings into the same cluster. A reasoning chain cluster represents a specific reasoning mode. The center reasoning chain is the most representative reasoning chain in the cluster, and the boundary reasoning chain is the chain farthest from the center.
[0088] Specifically, before computing the reward value, the system will first perform diversity analysis on the generated multiple sets of candidate reasoning chains. First, according to the length of each chain, it is divided into different groups to avoid the comparison bias caused by the long and short. Within each length group, the system uses a pre-trained sentence encoding model (such as Sentence-BERT) to convert each reasoning chain into a sentence vector. Then, apply clustering algorithms (such as K-Means or DBSCAN) to these vectors, and aggregate reasoning chains that are semantically similar (i.e. chains that describe the same reasoning logic) together to form several reasoning chain clusters. For each cluster, calculate the center (the average of all member vectors) and the boundary member farthest from the center. The compactness of the members within the cluster (the distance between the center and the boundary) and the distance between the centers of different clusters together reflect the diversity of the reasoning patterns. The system calculates a reasoning diversity coefficient based on these distances, which will be used as a multiplication factor or an addition item to adjust the correctness reward in the subsequent calculation, so as to encourage the model to generate more diverse and dispersed reasoning chains.
[0089] In some embodiments, the face liveness recognition system will introduce a density reward to improve the explanation quality, that is, the face liveness recognition system will extract key feature words in the central reasoning chain to construct a reasoning feature dictionary; based on the reasoning feature dictionary, the feature coverage of the candidate reasoning chain is evaluated, and the number of feature words covered by each candidate reasoning chain is calculated; the reasoning density index is determined according to the ratio of the number of feature words and the length of the candidate reasoning chain; based on the reasoning density index and the reasoning diversity coefficient, a composite adjustment factor is generated.
[0090] Wherein, the central reasoning chain is the core sample representing each type of reasoning pattern obtained after clustering in the previous link. The reasoning feature dictionary is a set containing important keywords related to liveness detection (such as moire, blinking, skin texture). Feature coverage evaluation is to check how many keywords in the dictionary are included in a reasoning chain. The reasoning density index quantifies the ratio of the information content of the reasoning chain to its length. The composite adjustment factor is a comprehensive reward adjustment item that combines diversity and information density.
[0091] Specifically, after the face liveness recognition system determines the inference chain cluster and the center inference chain, it further analyzes these representative center inference chains. The system extracts high-frequency appearing, directly related to liveness judgment nouns or verbs from them, and constructs or dynamically updates an inference feature dictionary. Then, for each newly generated candidate inference chain, the system checks its text content, and counts how many different keywords in the feature dictionary hit. This number divided by the total length of the inference chain (such as the number of words or sentences) gives the inference density index of the chain. A high-density inference chain means that it conveys rich key information in a short space. Finally, the system fuses this inference density index and the previously calculated inference diversity coefficient into a composite adjustment factor by weighted summation or multiplication, etc., to adjust the final reward value. This composite factor encourages the model to generate diverse and concise inference processes.
[0092] In some embodiments, it is necessary to build and maintain an inference feature dictionary. A static, manually defined dictionary may not be comprehensive enough to adapt to new features or new types of attacks discovered by the model. To this end, a semi-automatic dynamic dictionary updating mechanism can be used. The system can automatically mine new candidate feature words from the currently best-performing inference chains (i.e., the chains that obtain high rewards) through word frequency statistics, keyword extraction algorithms (such as TextRank), etc. on a regular basis (e.g., every training cycle). Then, these candidate words can be manually reviewed and screened, and after confirmation, they are added to the inference feature dictionary. This human-machine combined approach not only ensures that the dictionary can keep pace with the times and dynamically expand, but also ensures the quality and accuracy of the dictionary through manual review, so that it can better guide the model to learn and generate high-quality inferences.
[0093] S305, calculate a baseline value based on the plurality of output reward values, and determine a difference between each output reward value and the baseline value as a corresponding advantage value.
[0094] wherein the baseline value (Baseline) is a reference point for evaluating the relative level of the reward value, which is an expected estimate of all reward values in the current batch. The advantage value is an index that measures how much better a particular action (here, generating a particular inference chain) is than the average level.
[0095] Specifically, after obtaining the G candidate inference chains and their corresponding output reward values , ,..., }, the face liveness recognition system first needs to calculate a baseline value V. The simplest implementation is to take the arithmetic mean of the G reward values as the baseline value, i.e., V = (1 / G) * Σ ( ). Subsequently, the system iterates through each candidate inference chain , and calculates the difference between its corresponding reward value Its dominance value is calculated by comparing it with the baseline value V. = -V. If A positive value indicates that a reasoning chain has been generated. This sequence of behaviors yielded above-average returns, which is good behavior; if A negative value indicates bad behavior; a value close to zero indicates mediocre performance. This set of dominance values { , ,..., This will be used as the input for the next step of calculating the policy gradient, and the variance of the reward signal is reduced by centralization.
[0096] S306. Calculate the policy gradient based on the action probabilities and corresponding advantage values of the candidate inference chain during the generation process, and determine the update amount of the weight parameters of each layer in the policy network.
[0097] Here, action probability refers to the probability that the policy network selects a specific word (action) at each step in generating the candidate inference chain. Policy gradient is the gradient of the loss function with respect to the policy network parameters, generally updated in the direction of maximizing the expected reward. Weight parameter update amounts are specific values that need to be increased or decreased based on the current parameters, calculated using the policy gradient and learning rate.
[0098] Specifically, for each candidate inference chain (It consists of a series of actions) The sequence of components), the face liveness recognition system first needs to calculate the total probability P of generating this chain ( This refers to each action in the sequence. The product of conditional probabilities. Then, according to the policy gradient theorem, the gradient estimate of the expected return can be expressed as Σ[ θlogP( )* ],in θ represents the gradient with respect to the parameter θ. This is the advantage value calculated in step S305. The system calculates this gradient value; for inference chains with a positive advantage value, their generation probability should be increased; for chains with a negative advantage value, their probability should be decreased. Finally, the calculated policy gradient is multiplied by a preset learning rate α to obtain the final weight parameter update Δθ = α * θJ(θ), this update value will be used for the next parameter update.
[0099] In some embodiments, it is necessary to optimize sample efficiency. Basic policy gradient methods (such as REINFORCE) are on-policy; after each parameter update, previously collected samples become invalid and must be resampled with the new policy, resulting in low data utilization. To address this, an off-policy gradient calculation method can be employed, combined with importance sampling. Specifically, the system can store (state, action, reward) samples in an experience replay pool. When calculating the gradient, a batch of samples from the pool, generated under the old policy, is drawn... The generated samples are then weighted by importance (the ratio of the probability of the new strategy to that of the old strategy). (a|s) / (a|s) is used to correct the gradient calculation formula so that it can estimate the current policy unbiasedly. The gradient can be used to reuse historical data, improving sample efficiency and training speed.
[0100] In some embodiments, the face liveness recognition system performs gradient clipping to stabilize the training process. Specifically, when the gradient norm of the weight parameter update exceeds a preset threshold range, the face liveness recognition system performs gradient clipping on the weight parameter update, scaling the gradient components that exceed the range to the preset threshold range to obtain the clipped parameter update. The weight parameters of the policy network are updated based on the clipped parameter update to obtain the corrected policy network.
[0101] Specifically, after the face liveness detection system calculates the update amount (i.e., gradient) of the weight parameters through the policy gradient, a check is performed before the actual update operation. The system calculates the L2 norm of the entire gradient vector (i.e., the square root of the sum of the squares of all gradient components). Then, this norm is compared with a preset threshold (e.g., 1.0). If the norm is less than or equal to the threshold, it means that the gradient is within the normal range and no processing is needed; the gradient can be used directly for parameter updates. However, if the norm exceeds the threshold, it indicates a gradient explosion, and the update may be too large, compromising the stability of the model. In this case, the system scales the entire gradient vector proportionally so that its norm is exactly equal to the preset threshold. The scaled, more moderate gradient is the pruned parameter update amount, which the system uses to update the weights of the policy network, resulting in a stabilized and corrected policy network.
[0102] In some embodiments, it is necessary to select an appropriate clipping threshold. If the threshold is set too high, gradient clipping will not work and will not prevent gradient explosion; if the threshold is set too low, it will excessively restrict the model's update pace, resulting in slower training speed and even failure to learn effective policies. This threshold needs to be adjusted based on experience and experimentation. To address this, the norm distribution of gradients can be dynamically monitored during training. The gradient norm for each training batch can be recorded and its histogram or time series plotted. By observing this distribution, the typical range of gradients during normal training can be understood. Based on this observation, a value slightly higher than the upper limit of the normal range can be selected as the clipping threshold (e.g., choosing a value at the 95th percentile).
[0103] S307. Update the weight parameters of the policy network based on the weight parameter update amount to obtain the optimized policy network.
[0104] The weight parameter update amount is the result of multiplying the gradient calculated in step S306 by the learning rate. Updating the weight parameters of the policy network means adding this update amount to the existing parameter values. Optimizing the policy network refers to the new version of the policy network whose performance is improved after this update step.
[0105] Specifically, after the face liveness detection system calculates the update amount Δθ of the weight parameters for each layer, it performs a parameter update operation. This process is very straightforward; for each weight parameter in the policy network... Its new value Will equal the old value Add the corresponding update amount Δ That is, θ' = θ + Δθ. This operation is automatically performed by the optimizer in deep learning frameworks (such as PyTorch or TensorFlow). For example, if using the stochastic gradient descent (SGD) optimizer, it will perform the simple addition operation described above. After this step, the internal state of the policy network changes; it is now an optimized version, and theoretically, it will be more inclined to generate sequences that can obtain high rewards in the next generation of candidate inference chains. The entire loop from S303 to S307 will iterate multiple times until the model's performance reaches saturation or a preset stopping condition is met.
[0106] In some embodiments, parameter updates in this step can be implemented in several ways: Optionally, an optimizer with momentum (such as MomentumSGD) can be used, which considers not only the current gradient but also the cumulative direction of historical gradients (i.e., momentum) when updating parameters. The update rule becomes:
[0107] =β* +Δθ,θ'=θ+ This helps to accelerate convergence and overcome local minima.
[0108] Optionally, an optimizer with an adaptive learning rate (such as Adam or RMSprop) can be used. These optimizers maintain an independent learning rate for each parameter. A smaller learning rate is used for parameters with large gradients or frequent changes; a larger learning rate is used for parameters with small gradients or stable parameters. This makes the update process more efficient and stable, eliminating the need for manual fine-tuning of the learning rate. It is understood that various other advanced optimization algorithms can also be used to perform parameter updates; this is not limited to these methods.
[0109] S308. Determine the optimal inference chain based on the optimized strategy network, and determine the liveness detection result and inference process description based on the optimal inference chain.
[0110] The optimized policy network is the final model obtained after multiple rounds of iterative optimization in step S307. The optimal inference chain is the highest quality inference chain generated by this optimized network during the inference phase. The liveness detection results and inference process descriptions are the conclusions and analysis processes derived from this optimal inference chain.
[0111] Specifically, after the entire training process (loops S303-S307), the face liveness recognition system possesses a stable optimization policy network. When a new, unknown face image needs to be identified, the system enters inference mode to obtain the initial state vector of the image. This vector is then input into the optimization policy network. Unlike the random sampling used during training, in inference employs deterministic or near-deterministic decoding strategies, such as greedy search (selecting the word with the highest probability at each step) or bundle search, to obtain the most reliable results. This generates one or more most probable inference chains, selecting the optimal one. Finally, the system analyzes this optimal inference chain, using its conclusion (e.g., liveness) as the final identification result and the analysis process (e.g., clear image, micro-expression changes) as explanation, thus completing a full and interpretable liveness recognition task.
[0112] In some embodiments, it is necessary to improve the generalization ability of the model. That is, can an optimized policy network that performs well on the training set still generate correct and reasonable inference chains when faced with novel attacks or rare scenarios in the real world that differ from the distribution of the training data? The model's knowledge may be limited to patterns seen in the training data. To address this, an uncertainty assessment step can be added after determining the optimal inference chain. Techniques such as Monte Carlo dropout can be used to perform multiple (e.g., 10) randomized forward propagations during inference, generating 10 different inference chains. If the conclusions of these 10 chains are highly consistent (e.g., all 10 are determined to be live), the model is considered to be very confident in its current judgment, with low uncertainty. If the conclusions are divergent (e.g., 6 live, 4 attacks), the model is considered to have high uncertainty in its current judgment. For results with high uncertainty, the system can mark them and forward them to human review, thereby avoiding giving incorrect but seemingly reasonable explanations when the model's confidence is low.
[0113] S309. Perform reverse verification on the optimal inference chain, take the liveness detection result as the assumption premise input into the verification model, and derive the verification features corresponding to the original image features based on the reverse inference path.
[0114] Here, the assumption is that the conclusion is considered a known truth. A verification model is a model or algorithm capable of performing backward reasoning. A backward reasoning path is the logical path that traces back from the conclusion to the initial evidence supporting it. Verification features are feature vectors generated through backward reasoning that should theoretically match the features of the original image.
[0115] Specifically, after the face liveness recognition system determines the optimal inference chain and its judgment result through step S308, in order to further ensure the reliability of the inference, the system will initiate a reverse verification process. It takes the judgment result (e.g., a determination of a screen attack) as input and feeds it into a verification model. This verification model is designed to answer a reverse question: "If the conclusion is 'screen attack,' then at the feature level, what features should the original image possess?" Based on its internal knowledge (e.g., "screen attack" is associated with features such as "moiré patterns" and "screen reflections"), the verification model deduces along a path logically opposite to the optimal inference chain, ultimately generating a virtual feature vector in the feature space, i.e., the verification feature. The verification feature represents the feature representation of a typical input image given a conclusion.
[0116] In some embodiments, this step of reverse reasoning and feature generation can be implemented in several ways: Optionally, the decoder part of a Generative Adversarial Network (GAN) or Variational Autoencoder (VAE) can be used as the verification model. The discrimination result is encoded into a conditional vector and input into the decoder to directly generate a verification feature vector that meets the condition. Optionally, knowledge graph-based reasoning can be used. First, a knowledge graph containing liveness / attack features and their relationships is constructed; the discrimination result is used as the query starting point, and a reverse search is performed on the graph to find all the low-level feature nodes that support the conclusion; then, the feature vectors corresponding to these feature nodes are weighted and combined to generate the final verification feature. It is understood that other generative models or symbolic reasoning methods can also be used to implement reverse feature generation, which is not limited here.
[0117] In some embodiments, a conclusion may be reached by a combination of different pieces of evidence. For example, an attack on this conclusion might stem from evidence of a photographic reproduction or from evidence of a 3D mask. If the reverse verification model simply selects a possibility randomly to generate a verification feature, its verification results may be inaccurate. Therefore, the reverse verification process should be guided by a forward inference chain. Specifically, when performing reverse verification, not only should the final judgment result be input, but also the key analytical steps in the optimal inference chain (such as detecting moiré patterns) should be input as constraints into the verification model. This makes the verification model's objective clearer, generating a specific verification feature that conforms to the logic that the presence of moiré patterns indicates an attack, thereby improving the targeting and accuracy of the reverse verification.
[0118] In some embodiments, the face liveness detection system performs reverse verification through feature reconstruction. Specifically, the system converts the liveness detection result into a set of feature constraints. This set includes essential liveness feature conditions and exclusion conditions for non-liveness features. Based on the set of feature constraints, constraint solving is performed in a multi-dimensional feature space to determine candidate feature regions that satisfy either the essential liveness feature conditions or the exclusion conditions for non-liveness features. Key feature vectors are extracted from these candidate regions according to their importance weights, and these vectors are arranged in reverse order of inference to generate a reverse feature sequence. The image feature representation is reconstructed based on the reverse feature sequence to generate verification features corresponding to the original image features.
[0119] The feature constraint set is a concrete description of the discrimination result; for example, a living organism must have skin texture and cannot have moiré patterns. The feature candidate region is the set of all points in the high-dimensional feature space that satisfy these constraints. The key feature vector refers to the feature components in these regions that have the greatest influence on the discrimination. The reverse feature sequence is a sequence of feature vectors that simulates the reverse reasoning process.
[0120] Specifically, when the result indicates a liveness detection, the face liveness recognition system converts it into a set of constraints, such as the skin texture dimension value must be greater than a certain threshold (a prerequisite), while the moiré pattern dimension value must be less than a certain threshold (an exclusion condition). In the feature space defined by the visual encoder, the system finds a subspace consisting of all points satisfying these constraints, i.e., the feature candidate region. Next, based on pre-learned or defined feature importance, the system extracts the most important feature vector (such as the vector representing skin texture) from this region. If the forward inference is that the presence of skin texture indicates liveness, then the reverse sequence is this feature vector representing the skin texture. Finally, the system uses a decoder or inverse transform to reconstruct a complete image feature representation based on this reverse feature sequence, i.e., the verification feature.
[0121] In some embodiments, feature reconstruction in this step can be achieved in several ways: Optionally, an optimization-based approach can be used, defining the generation of verification features as an optimization problem. The goal is to find a feature vector x such that, while satisfying constraints, its discrimination result obtained by a pre-trained classifier is most consistent with the given liveness discrimination result. Solving this optimization problem using methods such as gradient descent yields the verification feature x. Optionally, a generative model-based approach can be used, training a conditional generative model (such as cGAN or cVAE) whose input is the discrimination result and key evidence description, and whose output is the corresponding image features. During verification, the conditions are directly input into this model to generate verification features. This method is fast but requires additional model training. It is understood that other constraint solving and feature generation techniques can also be used, and are not limited here.
[0122] S310. Calculate the similarity between the verification features and the original image features to obtain the feature matching degree.
[0123] Among them, the feature matching degree is a numerical value obtained after similarity calculation, which represents the degree of conformity between the theoretical features generated in reverse and the actual features extracted in forward.
[0124] Specifically, after acquiring the verification features generated in step S309 and the original image features saved in step S302, the face liveness recognition system needs to compare the two. Both vectors reside in the same high-dimensional feature space. The system employs a vector similarity or distance metric to calculate their consistency. For example, cosine similarity can be used to calculate the cosine of the angle between two vectors; the closer this value is to 1, the more consistent the directions of the two vectors, and the better the feature match. Alternatively, Euclidean distance can be used to calculate the straight-line distance between two points in space; the smaller the distance, the better the feature match. This calculated value, the feature matching degree, directly reflects whether the expected features derived from the conclusion match the actual features in the image.
[0125] In some embodiments, similarity calculation in this step can be implemented in several ways: Optionally, a weighted Lp norm distance can be used, assigning different weights to different dimensions of the feature vector based on their importance for liveness detection; when calculating the distance, differences in important dimensions are penalized more, making the similarity calculation focus more on key features. Optionally, a kernel function-based method, such as the Gaussian kernel function, can be used to map the two vectors to a higher-dimensional space before calculating their inner product; this non-linear method can capture more complex feature relationships and is more powerful than simple linear similarity measures. It is understood that various other distance or similarity measurement functions can also be used, and no limitation is made here.
[0126] S311. Based on the feature matching degree, calculate the inference reversibility score of the reverse inference path and the optimal inference chain.
[0127] Among them, the reverse reasoning path and the optimal reasoning chain represent two logical chains, one from the conclusion to the evidence and the other from the evidence to the conclusion. The reasoning reversibility score is a comprehensive index used to quantify whether these two paths are logically consistent and inverse processes.
[0128] Specifically, the face liveness recognition system uses the feature matching degree obtained in step S310 as the core basis to calculate the final inference reversibility score. The most direct approach is to use the feature matching degree itself (or after normalization) as the inference reversibility score. For example, if the feature matching degree (such as cosine similarity) is 0.95, the inference reversibility score could be 95. This score intuitively reflects the consistency between deriving from A to B and deriving back from B to A. A high reversibility score means that the logic of the forward inference chain is very robust, and its conclusion can well explain the evidence it relies on, and vice versa. This score is the final quantitative evaluation of the quality of the optimal inference chain and is the decisive indicator for judging its reliability.
[0129] In some embodiments, the scoring calculation for this step can be implemented in several ways: Optionally, a multi-index fusion scoring method can be used. In addition to feature matching degree, the semantic similarity between the forward and backward reasoning paths can also be calculated (e.g., using sentence embedding to compare the presence of moiré patterns in an image and the key evidence derived from backward reasoning is moiré patterns), and the semantic similarity is weighted and fused with the feature matching degree to obtain a more comprehensive reversibility score. Optionally, a probability-based scoring method can be used, treating the feature matching degree as a conditional probability P(original feature | discrimination result), and combining it with the probability P(discrimination result | original feature) of forward reasoning, a posterior probability is calculated as the reversibility score using Bayes' theorem or other methods. This approach has a more solid theoretical foundation within the framework of probability theory. Understandably, other more complex functions can also be designed to generate the final reversibility score from the feature matching degree, which is not limited here.
[0130] In some embodiments, a finer-grained decomposable evaluation can be performed simultaneously with the calculation of the total score. For example, if the feature vector is multidimensional, it can be decomposed into subspaces corresponding to different semantic concepts (such as a texture feature subspace and a color feature subspace). When calculating the feature matching degree, the matching degree in each subspace can be calculated separately. Ultimately, the system not only provides an overall reversibility score but also includes a diagnostic report, such as: a total inference reversibility score of 85. Among these, the texture feature matching degree is high (98 points), but the color feature matching degree is low (70 points).
[0131] S312. When the reasoning reversibility score is lower than the preset reversibility threshold, a suboptimal reasoning chain is selected from the candidate reasoning chains, and the suboptimal reasoning chain is reverse-verified.
[0132] The preset reversibility threshold is a pre-set standard used to determine whether the reasoning process is reliable enough.
[0133] Specifically, the face liveness recognition system compares the inference reversibility score calculated in step S311 with a pre-set reversibility threshold (e.g., 90 points). If the score is higher than or equal to the threshold, it indicates that the current optimal inference chain is logically sound and highly reliable, and the verification passes, ending the entire recognition process. However, if the score is lower than the threshold, the system determines that the current optimal inference chain may have logical flaws or be inconsistent with the facts, and its reliability is questionable. In this case, the system will not directly accept this problematic inference, but will initiate a rollback and retry mechanism. It will select the second-highest score (i.e., the suboptimal inference chain) from the previously generated set of candidate inference chains, and then, starting from step S309, repeat the same reverse verification process for this suboptimal inference chain. This process will continue until an inference chain that can pass the reverse verification is found, or all high-quality candidate chains fail verification.
[0134] In some embodiments, the suboptimal chain selection and retry in this step can be implemented in several ways: Optionally, an ordered backoff strategy can be adopted. If a beam search is used in step S308 to generate k candidate chains, these k chains are themselves sorted by quality. When the optimal chain (the first chain) fails to be verified, the system automatically selects the second chain for verification. If that fails, the third chain is selected, and so on, until success is achieved or all k chains have been traversed. Optionally, a dynamic regeneration strategy can be adopted. If all initial candidate chains fail to be verified, the system can consider the initial generation quality to be generally low. In this case, the policy network can be called again, but with different sampling parameters (e.g., a higher temperature to increase diversity), to regenerate a completely new batch of candidate inference chains, and then the optimal chain is selected from this new batch for verification. It is understood that multiple strategies can also be combined to handle the verification failure situation, which is not limited here.
[0135] In some embodiments, strategy switching may fall into an infinite loop or be excessively time-consuming. If all candidate inference chains are of poor quality, repeated reverse verification will consume significant computational resources without yielding usable results. Therefore, a clear termination condition needs to be set. For example, the number of retries can be limited (maximum of 5 candidate chains to verify). If, after the specified number of attempts, no valid inference chain is found, the system should stop retrying and output a final status that is uncertain or requires manual review, rather than forcibly providing an unreliable conclusion. Simultaneously, the system should log all failed inference chains and the detailed verification process; this is invaluable failure sample data for subsequent model analysis and iterative optimization.
[0136] In this embodiment, by employing a multimodal large model and a self-constructed interpretable inference chain based on reinforcement learning, combined with a series of techniques such as efficient optimization based on the dominance function, quality improvement based on diversity and density rewards, and reliability verification based on reverse verification, the face liveness detection system can not only make accurate liveness detections but also generate a logically clear, detailed, and formatted structured text explanation for each detection result. This optimizes the black-box problem inherent in traditional deep learning methods in face liveness detection, improving the system's reliability and user trust in high-security application scenarios such as finance and security. It also provides directional support for professionals to optimize and update the model, thus promoting the technological development of face recognition.
[0137] The face liveness recognition system in the embodiments of this invention is described below from the perspective of hardware processing. Please refer to [link / reference]. Figure 4 This is a schematic diagram of the physical device structure of a face liveness recognition system in this application embodiment.
[0138] It should be noted that, Figure 4 The structure of the face liveness recognition system shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of the present invention.
[0139] like Figure 4 As shown, the face liveness recognition system includes a CPU 401, which can perform various appropriate actions and processes according to a program stored in ROM 402 or a program loaded into RAM 403 from storage section 408, such as executing the methods described in the above embodiments. RAM 403 also stores various programs and data required for system operation. The CPU 401, ROM 402, and RAM 403 are interconnected via bus 404. I / O interface 405 is also connected to bus 404.
[0140] The following components are connected to I / O interface 405: input section 406 including audio input devices, push-button switches, etc.; output section 407 including a liquid crystal display (LCD) and audio output devices, indicator lights, etc.; storage section 408 including a hard disk, etc.; and communication section 409 including a network interface card such as a LAN (Local Area Network) card, modem, etc. Communication section 409 performs communication processing via a network such as the Internet. Drive 410 is also connected to I / O interface 405 as needed. Removable media 411, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., are installed on drive 410 as needed so that computer programs read from them can be installed into storage section 408 as needed.
[0141] In particular, according to embodiments of the present invention, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of the present invention include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing computer programs for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication section 409, and / or installed from removable medium 411. When the computer program is executed by CPU 401, it performs the various functions defined in the present invention.
[0142] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present invention. Each block in a flowchart or block diagram may represent a module, program segment, or portion of code, which contains one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those shown in the drawings.
[0143] Specifically, the face liveness recognition system of this embodiment includes a processor and a memory. The memory stores a computer program. When the computer program is executed by the processor, it implements the face liveness recognition method with a self-constructed inference chain provided in the above embodiment.
[0144] In another aspect, the present invention also provides a computer-readable storage medium, which may be included in the face liveness recognition system described in the above embodiments; or it may exist independently and not assembled into the face liveness recognition system. The storage medium carries one or more computer programs, which, when executed by a processor of the face liveness recognition system, cause the face liveness recognition system to implement the self-constructed inference chain face liveness recognition method provided in the above embodiments.
[0145] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit it. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application.
[0146] As used in the above embodiments, depending on the context, the term "when..." can be interpreted as meaning "if..." or "after..." or "in response to determining..." or "in response to detecting...". Similarly, depending on the context, the phrase "when determining..." or "if (the stated condition or event) is interpreted as meaning "if determining..." or "in response to determining..." or "when (the stated condition or event) is detected" or "in response to detecting (the stated condition or event)".< / answer> < / think> < / answer> < / think>
Claims
1. A face liveness detection method with a self-constructed inference chain, characterized in that, The method, applied to a face liveness recognition system, includes: Face detection and face segmentation are performed on the initial face image, and then normalized to form a standard face image; Based on a multimodal large model, the standard face image and the preset task instruction text used to guide the liveness detection task are respectively feature encoded to obtain image feature vectors and text feature vectors, which serve as the initial state of the reinforcement learning environment. The initial state is input into the policy network, and multiple sets of candidate reasoning chains are generated by sampling the policy network multiple times; the candidate reasoning chains are structured text formats that include reasoning processes and judgment answers. The method further includes: calculating a correctness reward based on the tag matching degree between the candidate inference chain and the real label, calculating a format standardization reward based on the text matching degree between the candidate inference chain and the structured text format, and determining multiple output reward values for the multiple groups of candidate inference chains; prior to the steps of calculating the correctness reward based on the tag matching degree between the candidate inference chain and the real label, calculating the format standardization reward based on the text matching degree between the candidate inference chain and the structured text format, and determining multiple output reward values for the multiple groups of candidate inference chains, the method further includes: grouping the candidate inference chains according to the number of inference steps to obtain multiple inference length groups; performing semantic similarity clustering on the candidate inference chains within each inference length group to obtain multiple inference chain clusters with the same inference pattern; determining the central inference chain and the boundary inference chain in each inference chain cluster; and determining an inference diversity coefficient based on the semantic distance between the central inference chain and the boundary inference chain as an adjustment factor in the calculation formula of the correctness reward; A dominance function is calculated for the multiple candidate inference chains and their corresponding output reward values, and the weight parameters of the policy network are adjusted based on the dominance function to obtain an optimized policy network. The optimal inference chain is determined based on the optimized strategy network, and the liveness detection result and inference process description are determined based on the optimal inference chain. The optimal inference chain is reverse-verified, and the liveness detection result is used as an assumption to input into the verification model. Verification features corresponding to the original image features are generated based on the reverse inference path. The similarity between the verification features and the original image features is calculated to obtain the feature matching degree; Based on the feature matching degree, calculate the reasoning reversibility score of the reverse reasoning path and the optimal reasoning chain; When the reasoning reversibility score is lower than the preset reversibility threshold, a suboptimal reasoning chain is selected from the candidate reasoning chains, and the suboptimal reasoning chain is reverse-verified.
2. The method according to claim 1, characterized in that, The step of calculating an advantage function for the multiple candidate inference chains and their corresponding output reward values, and adjusting the weight parameters of the policy network based on the advantage function to obtain an optimized policy network, specifically includes: A baseline value is calculated based on the multiple output reward values, and the difference between each output reward value and the baseline value is determined as the corresponding advantage value. The policy gradient is calculated based on the action probability and corresponding advantage value of the candidate inference chain during the generation process, and the weight parameter update amount of each layer in the policy network is determined. The weight parameters of the policy network are updated based on the weight parameter update amount to obtain the optimized policy network.
3. The method according to claim 2, characterized in that, After the step of calculating the policy gradient based on the action probabilities and corresponding advantage values of the candidate inference chain during the generation process, and determining the weight parameter update amount of each layer in the policy network, the method further includes: When the gradient norm of the weight parameter update exceeds a preset threshold range, a gradient clipping operation is performed on the weight parameter update to scale the gradient components that exceed the range to the preset threshold range, thereby obtaining the clipped parameter update. The weight parameters of the policy network are updated based on the pruning parameter update amount to obtain the modified policy network.
4. The method according to claim 1, characterized in that, After the step of determining the central inference chain and the boundary inference chain in each of the inference chain clusters, the method further includes: Extract key feature words from the central inference chain and construct an inference feature dictionary; Based on the inference feature dictionary, the feature coverage of the candidate inference chains is evaluated, and the number of feature words covered by each candidate inference chain is calculated. The inference density index is determined based on the ratio of the number of feature words to the length of the candidate inference chain; A composite adjustment factor is generated based on the inference density index and the inference diversity coefficient.
5. The method according to claim 1, characterized in that, The step of reverse-verifying the optimal inference chain, using the liveness detection result as an assumption input into the verification model, and deriving verification features corresponding to the original image features based on the reverse inference path, specifically includes: The liveness detection result is converted into a set of feature constraints; the set of feature constraints includes necessary liveness feature conditions and exclusion conditions for non-liveness features; Based on the set of feature constraints, constraint solving is performed in the multidimensional feature space to determine the feature candidate regions that satisfy the necessary conditions for live features or the exclusion conditions for non-live features. Key feature vectors are extracted from the feature candidate regions according to feature importance weights, and the key feature vectors are arranged in reverse order of reasoning to generate a reverse feature sequence. Based on the inverse feature sequence, the image feature representation is reconstructed to generate verification features corresponding to the original image features.
6. A facial liveness recognition system, characterized in that, The face liveness recognition system includes: one or more processors and a memory; the memory is coupled to the one or more processors, the memory is used to store computer program code, the computer program code includes computer instructions, and the one or more processors call the computer instructions to cause the face liveness recognition system to perform the method as described in any one of claims 1-5.
7. A computer-readable storage medium comprising instructions, characterized in that, When the instructions are executed on the face liveness recognition system, the face liveness recognition system performs the method as described in any one of claims 1-5.
8. A computer program product, characterized in that, When the computer program product is run on the face liveness recognition system, the face liveness recognition system performs the method as described in any one of claims 1-5.
Citation Information
Patent Citations
Face living body detection method and device
CN119479027A
Multimodal large model task processing method, device and equipment based on reinforcement learning
CN120632683A